#|QT连接多个数据库

addDatabase第二个参数

//操作数据库1 QSqlQuery query; //默认数据库1 query.exec("select * from student"); //操作数据库2 QSqlDatabase db2 = QSqlDatabase::database("a"); //连接数据库2 QSqlQuery query(db2); //绑定db2 query.exec("select * from teacher");

[static] QSqlDatabase QSqlDatabase::addDatabase(QSqlDriver *driver, const QString &connectionName = QLatin1String(defaultConnection))

**This overload is useful when you want to create a database connection with a driver you instantiated yourself. It might be your own database driver, or you might just need to instantiate one of the Qt drivers yourself. If you do this, it is recommended that you include the driver code in your application. For example, you can create a PostgreSQL connection with your own QPSQL driver like this:**

    推荐阅读