# Best practice for Database Open and Close connection

**URL:** <https://forum.golangbridge.org/t/best-practice-for-database-open-and-close-connection/19021>\
**Category:** Getting Help\
**Created:** [May 21, 2020, 10:53pm UTC](https://forum.golangbridge.org/t/best-practice-for-database-open-and-close-connection/19021 "2020-05-21T22:53:19Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![skillian](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/skillian/32/7876_2.png) [@skillian](https://forum.golangbridge.org/u/skillian)\
**Post date:** [May 21, 2020, 11:51pm UTC](https://forum.golangbridge.org/t/best-practice-for-database-open-and-close-connection/19021/2 "2020-05-21T23:51:47Z")

</div>

It’s hard for us to answer without seeing your code. You _probably_ don’t need to do that unless you’re, for example, connecting to different databases each time.

The last paragraph of the `sql.Open` documentation says:

> The returned DB is safe for concurrent use by multiple goroutines and maintains its own pool of idle connections. Thus, the Open function should be called just once. It is rarely necessary to close a DB.

Show us your code and we can give a more concrete answer.

---

_[View the full topic](https://forum.golangbridge.org/t/best-practice-for-database-open-and-close-connection/19021)._
