update views and orders

This commit is contained in:
2025-10-04 09:37:10 +03:00
parent 395433d4c3
commit e1438a476b
6 changed files with 228 additions and 3001 deletions

View File

@@ -0,0 +1,50 @@
import mariadb
# Database connection credentials
DB_CONFIG = {
"user": "trasabilitate",
"password": "Initial01!",
"host": "localhost",
"database": "trasabilitate_database"
}
def recreate_order_for_labels_table():
conn = mariadb.connect(**DB_CONFIG)
cursor = conn.cursor()
print("Connected to the database successfully!")
# Drop the table if it exists
cursor.execute("DROP TABLE IF EXISTS order_for_labels")
print("Dropped existing 'order_for_labels' table.")
# Create the table with the new unique constraint
create_table_sql = """
CREATE TABLE order_for_labels (
id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique identifier',
comanda_productie VARCHAR(15) NOT NULL UNIQUE COMMENT 'Production Order (unique)',
cod_articol VARCHAR(15) COMMENT 'Article Code',
descr_com_prod VARCHAR(50) NOT NULL COMMENT 'Production Order Description',
cantitate INT(3) NOT NULL COMMENT 'Quantity',
data_livrare DATE COMMENT 'Delivery date',
dimensiune VARCHAR(20) COMMENT 'Dimensions',
com_achiz_client VARCHAR(25) COMMENT 'Client Purchase Order',
nr_linie_com_client INT(3) COMMENT 'Client Order Line Number',
customer_name VARCHAR(50) COMMENT 'Customer Name',
customer_article_number VARCHAR(25) COMMENT 'Customer Article Number',
open_for_order VARCHAR(25) COMMENT 'Open for Order Status',
line_number INT(3) COMMENT 'Line Number',
printed_labels TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Boolean flag: 0=labels not printed, 1=labels printed',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'Record creation timestamp',
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Record update timestamp'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Table for storing order information for label generation';
"""
cursor.execute(create_table_sql)
print("Created new 'order_for_labels' table with unique comanda_productie.")
conn.commit()
cursor.close()
conn.close()
print("Done.")
if __name__ == "__main__":
recreate_order_for_labels_table()