diff --git a/doc/Programmstart Diagramm.drawio b/doc/Programmstart Diagramm.drawio index 40a9842..1aea176 100644 --- a/doc/Programmstart Diagramm.drawio +++ b/doc/Programmstart Diagramm.drawio @@ -35,78 +35,15 @@ - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + - - - - - @@ -127,58 +64,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -193,19 +78,153 @@ - - + + - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -213,10 +232,10 @@ - + - - + + @@ -224,34 +243,44 @@ - + - - + + - + + + + + + + - - + + - + - - - - - - - + + - - + + + + + + - - + + + + + + + diff --git a/doc/Programmstart Diagramm.pdf b/doc/Programmstart Diagramm.pdf index 787eb50..259a89a 100644 Binary files a/doc/Programmstart Diagramm.pdf and b/doc/Programmstart Diagramm.pdf differ diff --git a/lib/ConfigLoader.py b/lib/ConfigLoader.py index 990bf62..7b25cf1 100644 --- a/lib/ConfigLoader.py +++ b/lib/ConfigLoader.py @@ -6,6 +6,7 @@ from PySide6.QtCore import QObject, Slot from .Vermasseln import Vermasseln import shutil from urllib.parse import urlparse +import os class ConfigLoader(QObject): __config = None @@ -22,12 +23,13 @@ class ConfigLoader(QObject): @Slot(str, str) def importConfig(self, confile, password): - print(password) confile = urlparse(confile) - print(confile.path) - #confile= confile.replace('file://','') - shutil.copyfile(confile.path, self.config_dir+ '/pyqcrm.toml') + confile = confile.path + + if os.name == "nt": + confile = confile[1:] + shutil.copyfile(confile, self.config_dir+ '/pyqcrm.toml') @Slot(dict) def setConfig(self, app_config): @@ -50,7 +52,7 @@ class ConfigLoader(QObject): def getConfig(self): - + print(self.__config['database']) return self.__config def createConfig(self): diff --git a/lib/BusinessModel.py b/lib/DB/BusinessModel.py similarity index 100% rename from lib/BusinessModel.py rename to lib/DB/BusinessModel.py diff --git a/lib/DB/DbManager.py b/lib/DB/DbManager.py new file mode 100644 index 0000000..f01a2cc --- /dev/null +++ b/lib/DB/DbManager.py @@ -0,0 +1,22 @@ +# This Python file uses the following encoding: utf-8 +import toml +import mysql.connector + + +class DbManager(object): + __connection = None + __con_param = None + def __new__ (cls): + if not hasattr(cls, "__instance"): + cls.__instance = super().__new__(cls) + return cls.__instance + + def __init__ (self, dbconf): + __con_param = __initializeConfig(dbconf) + self.__connection = mysql.connector.connect(__con_param) + return self.__connection + + def __initializeConfig(self, dbconf): + __con_param = {'user': dbconf['DB_USER'], 'password': dbconf['DB_PASS'], 'port': dbconf['DB_PORT'], 'host': dbconf['DB_HOST'], 'name': dbconf['DB_NAME']} + return __con_param + diff --git a/lib/__init__.py b/lib/__init__.py index 5c3efa1..26aa708 100644 --- a/lib/__init__.py +++ b/lib/__init__.py @@ -1,2 +1,2 @@ from .ConfigLoader import ConfigLoader -from .BusinessModel import BusinessModel +from .DB.BusinessModel import BusinessModel diff --git a/main.py b/main.py index 193f702..4423c10 100644 --- a/main.py +++ b/main.py @@ -5,10 +5,11 @@ from PySide6.QtGui import QGuiApplication from PySide6.QtQml import QQmlApplicationEngine from PySide6.QtCore import QResource from lib.ConfigLoader import ConfigLoader -from lib.BusinessModel import BusinessModel +from lib.DB.BusinessModel import BusinessModel import rc_pyqcrm import rc_qml import sqlite3 +import lib.DB.DbManager # [pyqcrm] # program-name="" @@ -21,19 +22,6 @@ import sqlite3 # 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, 'Tero', 'Krefeld'), - (3, 'Blabla','Paris') - """) - connection.commit() - return connection - if __name__ == "__main__": @@ -55,7 +43,7 @@ if __name__ == "__main__": config = ConfigLoader() - con = testConnection() + con = DbManager() bm = BusinessModel(con) if not config.getConfig(): diff --git a/pyqcrm.pyproject b/pyqcrm.pyproject index d3bd7d2..0c05c02 100644 --- a/pyqcrm.pyproject +++ b/pyqcrm.pyproject @@ -11,7 +11,7 @@ "Gui/CustomerTables.qml", "Gui/SearchBar.qml", "Gui/test.qml", - "lib/BusinessModel.py", + "lib/DB/BusinessModel.py", "Gui/EmployeTables.qml", "Gui/AddCustomer.qml", "pyqcrm.qrc", @@ -24,6 +24,7 @@ "images/addperson.svg", "images/filter.svg", "images/menu.svg", - "images/search.svg" + "images/search.svg", + "lib/DB/DbManager.py" ] }