From 7e27fd8887cc2109353d434cc7aaf3f9c3d8e9be Mon Sep 17 00:00:00 2001 From: ske087 Date: Tue, 22 Apr 2025 16:17:24 +0300 Subject: [PATCH] moved scripts to database scripts --- .../delet scan1_orders values.py | 30 +++++++++++++++++++ py_app/app/{ => db_create_scripts}/query.py | 0 py_app/app/{ => db_create_scripts}/test.py | 0 3 files changed, 30 insertions(+) create mode 100644 py_app/app/db_create_scripts/delet scan1_orders values.py rename py_app/app/{ => db_create_scripts}/query.py (100%) rename py_app/app/{ => db_create_scripts}/test.py (100%) diff --git a/py_app/app/db_create_scripts/delet scan1_orders values.py b/py_app/app/db_create_scripts/delet scan1_orders values.py new file mode 100644 index 0000000..a4f2050 --- /dev/null +++ b/py_app/app/db_create_scripts/delet scan1_orders values.py @@ -0,0 +1,30 @@ +import mariadb + +# Database connection credentials +def get_db_connection(): + return mariadb.connect( + user="trasabilitate", # Replace with your username + password="Initial01!", # Replace with your password + host="localhost", # Replace with your host + port=3306, # Default MariaDB port + database="trasabilitate_database" # Replace with your database name + ) + +try: + # Connect to the database + conn = get_db_connection() + cursor = conn.cursor() + + # Delete query + delete_query = "DELETE FROM scan1_orders" + cursor.execute(delete_query) + conn.commit() + + print("All data from the 'scan1_orders' table has been deleted successfully.") + + # Close the connection + cursor.close() + conn.close() + +except mariadb.Error as e: + print(f"Error deleting data: {e}") \ No newline at end of file diff --git a/py_app/app/query.py b/py_app/app/db_create_scripts/query.py similarity index 100% rename from py_app/app/query.py rename to py_app/app/db_create_scripts/query.py diff --git a/py_app/app/test.py b/py_app/app/db_create_scripts/test.py similarity index 100% rename from py_app/app/test.py rename to py_app/app/db_create_scripts/test.py