correct update to the database and database created for scan

This commit is contained in:
2025-04-22 16:12:17 +03:00
parent e51e4bf2bb
commit 1d6eadf540
9 changed files with 246 additions and 36 deletions

37
py_app/app/test.py Normal file
View File

@@ -0,0 +1,37 @@
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()
# Insert query
insert_query = """
INSERT INTO scan1_orders (operator_code, CP_full_code, OC1_code, OC2_code, quality_code, date, time)
VALUES (?, ?, ?, ?, ?, ?, ?)
"""
# Values to insert
values = ('OP01', 'CP12345678-0002', 'OC11', 'OC22', 000, '2025-04-22', '14:30:00')
# Execute the query
cursor.execute(insert_query, values)
conn.commit()
print("Test data inserted successfully into scan1_orders.")
# Close the connection
cursor.close()
conn.close()
except mariadb.Error as e:
print(f"Error inserting data: {e}")