#|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:**
推荐阅读
- Docker应用:容器间通信与Mariadb数据库主从复制
- 数据库设计与优化
- Android|Android install 多个设备时指定设备
- 数据库总结语句
- py连接mysql
- MySql数据库备份与恢复
- Android|Android BLE蓝牙连接异常处理
- 数据库|SQL行转列方式优化查询性能实践
- MySQL数据库的基本操作
- springboot整合数据库连接池-->druid