def set_databaseconnection():
'''
Setting connection with SQLite
'''
# TODO explicitly close database connection on exit
filepath = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'ResourceFiles', 'Database', 'Intg_osdag.sqlite')
db = QSqlDatabase.addDatabase("QSQLITE")
db.setDatabaseName(filepath)
if not db.open():
QMessageBox.critical(None, qApp.tr("Cannot open database"),
qApp.tr("Unable to establish a database connection.\n"
"This example needs SQLite support. Please read "
"the Qt SQL driver documentation for information "
"how to build it.\n\n"
"Click Cancel to exit."),
QMessageBox.Cancel)
return False
评论列表
文章目录