def set_databaseconnection():
'''
Setting connection with SQLite
'''
filepath = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'ResourceFiles', 'Database', 'Intg_osdag.sqlite')
db = QSqlDatabase.addDatabase("QSQLITE")
db.setDatabaseName(filepath)
# db.open()
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
# def set_databaseconnection():
# '''
# Setting connection with MySQL database
# '''
# db = QSqlDatabase.addDatabase("QMYSQL")
# db.setHostName("localhost")
# db.setPort(3306)
# db.setDatabaseName("OSDAG")
# db.setUserName("root")
# db.setPassword("root")
# db.open()
# logger.info("feching records from database")
评论列表
文章目录