Gorm: Cannot close database connection

Created on 30 Jul 2020  路  2Comments  路  Source: go-gorm/gorm

Your Question

By using Gorm v2 with Postgres, there is no db.Close() to close the database connection.
But it was in Gorm v1, and it is already shown in the new documentation (that sqlite example).
The number of connections to database grows as new connections are made.
How to close the connection to database using new Gorm v2?

Most helpful comment

Sorry, my bad, found it here in closed issues.

sqlDB, err := DB.DB()
sqlDB.Close()

Better add it somewhere into the documentation.

All 2 comments

Sorry, my bad, found it here in closed issues.

sqlDB, err := DB.DB()
sqlDB.Close()

Better add it somewhere into the documentation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rfyiamcool picture rfyiamcool  路  3Comments

hypertornado picture hypertornado  路  3Comments

kumarsiva07 picture kumarsiva07  路  3Comments

alanyuen picture alanyuen  路  3Comments

Ganitzsh picture Ganitzsh  路  3Comments