fixup! feat(db/InitializeDBData.py): Initialize db data

This commit is contained in:
Kirill committed 2025-11-14 14:10:20 +03:00
1 parent 991e512390
commit 7515116712
2 files changed
+60 -38

No files matched your search

+15 -14
View File
@@ -1,27 +1,28 @@
import sqlite3
import uuid
import json
from loguru import logger as log
def init_database():
conn = sqlite3.connect('products.db')
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS Category (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE,
atributes TEXT NOT NULL
)
''')
cursor.execute('''
CREATE TABLE IF NOT EXISTS Product (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
description TEXT,
price REAL,
image_path TEXT NOT NULL
)
''')
cursor.execute('''
CREATE TABLE IF NOT EXISTS Type (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
product_id INTEGER,
FOREIGN KEY (product_id) REFERENCES Product (id)
category INTEGER NOT NULL,
desc TEXT,
image_path TEXT,
size TEXT,
FOREIGN KEY (category) REFERENCES Category (id)
)
''')