diff --git a/joystick_diagrams/db/db_device_management.py b/joystick_diagrams/db/db_device_management.py index 86be005..a296ec7 100644 --- a/joystick_diagrams/db/db_device_management.py +++ b/joystick_diagrams/db/db_device_management.py @@ -2,7 +2,7 @@ from sqlite3 import connect DB_DIR = "data" -DB_NAME = "devices.db" +DB_NAME = "joystick_diagrams.db" TABLE_NAME = "devices" @@ -13,12 +13,12 @@ def create_new_db_if_not_exist(): cur.execute(f"CREATE TABLE IF NOT EXISTS {TABLE_NAME}(guid TEXT PRIMARY KEY, template_path TEXT)") -def add_update_device_template_path(guid: str, template_path: str): +def add_update_device_template_path(guid: str, template_path: str) -> bool: path = os.path.join(os.getcwd(), DB_DIR, DB_NAME) connection = connect(path) cur = connection.cursor() - cur.execute(f"SELECT * from {TABLE_NAME} WHERE guid = {guid}") + cur.execute("SELECT * from devices WHERE guid = ?", (guid,)) result = cur.fetchall() if result: @@ -32,6 +32,7 @@ def add_update_device_template_path(guid: str, template_path: str): cur.execute(query, params) connection.commit() + return True def get_device_template_path(guid: str): diff --git a/joystick_diagrams/db/db_init.py b/joystick_diagrams/db/db_init.py index 6c5c106..c4090b5 100644 --- a/joystick_diagrams/db/db_init.py +++ b/joystick_diagrams/db/db_init.py @@ -3,10 +3,15 @@ Author: Robert Cox """ +import logging + from joystick_diagrams.db import db_device_management, db_plugin_data, db_value_store +_logger = logging.getLogger(__name__) + -def init(): +def init() -> None: + _logger.info("Initialising datastores") db_device_management.create_new_db_if_not_exist() db_value_store.create_new_db_if_not_exist() db_plugin_data.create_new_db_if_not_exist() diff --git a/joystick_diagrams/db/db_plugin_data.py b/joystick_diagrams/db/db_plugin_data.py index cc8ef3a..e6aaae8 100644 --- a/joystick_diagrams/db/db_plugin_data.py +++ b/joystick_diagrams/db/db_plugin_data.py @@ -2,7 +2,7 @@ from sqlite3 import connect DB_DIR = "data" -DB_NAME = "plugins.db" +DB_NAME = "joystick_diagrams.db" TABLE_NAME = "plugins" diff --git a/joystick_diagrams/db/db_value_store.py b/joystick_diagrams/db/db_value_store.py index 01d2566..a51674f 100644 --- a/joystick_diagrams/db/db_value_store.py +++ b/joystick_diagrams/db/db_value_store.py @@ -2,7 +2,7 @@ from sqlite3 import connect DB_DIR = "data" -DB_NAME = "values.db" +DB_NAME = "joystick_diagrams.db" def create_new_db_if_not_exist():