#database connections, one or multiple?
3 messages · Page 1 of 1 (latest)
So yes, "open" one at the start and reuse it throughout your application. If a connection is already in use by another goroutine, it'll spawn a new connection. And reuse those connections in future, returning them to the pool once they're no longer in use.
Yeah, that should be perfectly fine. You can configure some of the connection pooling properties of sql.DB too.
https://go.dev/doc/database/manage-connections