Re: [go-nuts] Best practice for Database Open and Close connection

2020-05-27 Thread Marcin Romaszewicz
Behind the scenes, DB is actually a connection pool, not a single connection, which will open new connections when you need them. In our services - which do a LOT of DB work, we only open a single sql.DB connection and share it among all our handlers. Whenever a handler does a db.Whatever, the db

[go-nuts] Best practice for Database Open and Close connection

2020-05-27 Thread srikanth c
what is the best practice when we are using database\sql package for sql.Open and db.close(). I have scenario where i have to multiple function and each function is responsible to hit the database and fetch the data. In this case do we need write sql.open() and db.close() in each of those fun