Closed Oskar888 closed 5 months ago
I would not suggest to open and close for any request. The idea is to let the connection open until the driver is closed. Then, as the server configuration may change, it is better to check for any call if the driver is connected or not. In that case it is better to close and reopen it again.
For Q&A see here
Give a look also to #368 . There is a good example of how to manage the connection
Hello, I have a problem with how to connect to the database in my backend. Many clients will have access to the API, so I want good database connection support. Is it a good idea to simply use db.open() and db.close() after each single query? and how can I use the connection pool? I was also thinking about creating a singleton that will connect to the database on the first query? It would be useful to have some sample code on how to implement it :) Thank you in advance. PS. I'm writing here because I couldn't find another way to communicate with devs