Qt 6.11 is out! See what's new in the release
blog
Windows : QtSql.setDatabaseName not allow to connect to my SQLITE database
-
Hi geeks!
wonder why this piece of code does not work when a correct DB path is set to connect to my existing database. when no parameter is passed by it works fine but not the goal for me.from PySide2 import QtCore, QtWidgets, QtSql
import osdef createConnection(path=None):
db = QtSql.QSqlDatabase.addDatabase("QSQLITE") if path is None: db.setDatabaseName(":memory:") else: if os.path.exists(path) == False: raise(' file to connect to db does not exist') else: db.setDatabaseName(path) if not db.open(): print('Connection failed') return False else: return Truemypath = r"Qt_Pricers/IRS/NEWirsDB.db"
path = os.path.join(os.getcwd(), mypath)
print(createConnection())