pyqt5-21.多线程数据库连接错误
QSqlDatabasePrivate::database: requested database does not belong to the calling thread.连接数据库的名字不可以使用一个,创建一个随机数,保证不重复https://forum.qt.io/topic/113422/requested-database-does-not-belong-to-the-calling-
·
QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
连接数据库的名字不可以使用一个,创建一个随机数,保证不重复
https://forum.qt.io/topic/113422/requested-database-does-not-belong-to-the-calling-thread
https://blog.csdn.net/shawzg/article/details/96484966
'''
db_mutex = QMutex()
def connectdb():
db_mutex.lock()
db = QSqlDatabase.addDatabase('QSQLITE',str(random.random()))
db.setDatabaseName("db/database.db")
db_mutex.unlock()
if not db.open():
mess = "打开数据库 database.db 错误:\n" + db.lastError().text()
mbox = Messbox(mess)
globalv.gl_log_db.info(mess)
return None
return db
'''
更多推荐

所有评论(0)