working with PySide. I have a sqlite database as default database:
db1 = QtSql.QSqlDatabase.addDatabase("QSQLITE")
db1.setDatabaseName(path_of_db)
db1.open()
and a second database with connection name "second_db":
db2 = QtSql.QSqlDatabase.addDatabase("QSQLITE", "second_db")
db2.setDatabaseName(path_of_db)
db2.open()
query = QSql.QSqlQuery("second_db")
query.exec_("SELECT * FROM table_name")
Now i want to insert records from a table from db1
into a table from db2
. I have a model for db1. I know that I can insert record per record through the models. I also thought about writing the records from db1
in a file/variable and then insert these into db2
.
Is there a simpler/quicker solution maybe a sql-query? How can I solve the problem?
Thank you for your help ;-)