Hi,
On 28 May 2010, at 23:11, Scott Frankel wrote:
>
> Hi all,
>
> What's the best way to manage multiple database connections in an
> application? Specifically, how can I manage which db connection is used for
> models, queries, &c.?
>
>
> The documentation says that multiple connections can be declared with a
> unique name for each on calling addDatabase(). My simple implementation
> yields errors and doesn't seem to provide a means to load data or call
> queries on one or the other. For example,
>
> db2 = QtSql.QSqlDatabase.addDatabase("QPSQL")
> db2.setDatabaseName("foo_db")
>
> db1 = QtSql.QSqlDatabase.addDatabase("QSQLITE")
> db1.setDatabaseName(":memory:")
>
> This yields the following errors:
>
> ...
Have you tried using the two-parameter version of addDatabase(), where the
second parameter is the unique name? I believe that the code above is
creating, and then re-creating, the 'default' database.
Regards,
-- CMcP
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt