datenbankmodel
This commit is contained in:
19
main.py
19
main.py
@@ -4,7 +4,8 @@ from pathlib import Path
|
||||
from PySide6.QtGui import QGuiApplication
|
||||
from PySide6.QtQml import QQmlApplicationEngine
|
||||
from lib.ConfigLoader import ConfigLoader
|
||||
|
||||
from lib.DataBase import DataBase
|
||||
import sqlite3
|
||||
|
||||
# [pyqcrm]
|
||||
# program-name=""
|
||||
@@ -17,7 +18,18 @@ from lib.ConfigLoader import ConfigLoader
|
||||
# password=""
|
||||
# name=""
|
||||
# type=""
|
||||
|
||||
def testConnection():
|
||||
connection= sqlite3.connect(":memory:")
|
||||
cur= connection.cursor()
|
||||
cur.execute("CREATE TABLE test(id INTEGER primary key, Kundenname TEXT, Ort TEXT)")
|
||||
cur.execute("""
|
||||
INSERT INTO test VALUES
|
||||
(1, 'Gruva', 'Dusseldorf'),
|
||||
(2, 'Teroteroterotero', 'Krefeld'),
|
||||
(3, 'Blabla','Paris')
|
||||
""")
|
||||
connection.commit()
|
||||
return connection
|
||||
|
||||
|
||||
|
||||
@@ -32,10 +44,13 @@ if __name__ == "__main__":
|
||||
|
||||
config = ConfigLoader()
|
||||
|
||||
con = testConnection()
|
||||
dbm = DataBase(con)
|
||||
|
||||
if not config.getConfig():
|
||||
bad_config = True
|
||||
|
||||
engine.rootContext().setContextProperty("dbm", dbm)
|
||||
engine.rootContext().setContextProperty("bad_config", bad_config) # print(f"Fehler: {i}")
|
||||
engine.rootContext().setContextProperty("config", config)
|
||||
engine.load(qml_file)
|
||||
|
||||
Reference in New Issue
Block a user