-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to close connection in V2 #3145
Comments
This issue has been automatically marked as stale as it missing playground pull request link, checkout https://github.com/go-gorm/playground for details, it will be closed in 2 days if no further activity occurs. |
If yes, use it like: sqlDB, err := DB.DB()
sqlDB.Close() |
@jinzhu Thx for ur reply, but I get the following error without
How do I solve it? |
Don't |
@jinzhu Okaaay, thx I guess I know what should I do :). |
Why is it the most misused method? If an application needs to forcibly close or if the application crashes or somehow stops for any reason - cleanup is the first thing that comes in mind and what are your reason to oppose it? |
it is not necessary to close when crash, and you can still |
@jinzhu or anyone, can you clarify when you should and when you should not close the database connection in GORM v2? And why do you say that you do not need to close it? Will GORM v2 automatically close all open connections on both a clean application shutdown and when the application crashes? These details could be a good addition to the documentation page Connecting to a Database. |
- it is not necessary to close when crash, and you can still Close DB connection in V2 - go-gorm/gorm#3145
@jinzhu To put in other words, on application crash, if |
I don’t think it does, I’ve seen db.Transaction that got started but didn’t get finalized due to a shutdown. |
When I upgrade to V2, the
db.Close
method does not exist.So how to Close the connection of database in V2.
The text was updated successfully, but these errors were encountered: