Unsolved db connection live...
-
Hi, I'm wondering what is the best practice for creating database connections QDatabaseConnection ...
Do you open and close DB connection on every place you need it or you create a global pointer that open de connection at start of the program and close it at finish?..
What about a singleton for this?
Thanks...
-
Hi,
It depends on your use.
No pointer needed, no Singleton needed. Please read carefully the QSqlDatabase documentation. That class already provides all you need for management, no need for local copies.
-
@SGaist said in db connection live...:
QSqlDatabase
i see on documentation there is a static function called database, that should serve me.. isn't ?
Thanks
-
Yes it will. It's talked about in the details of the class.