feat(modefied)
This commit is contained in:
1 parent
d705f2f9d3
commit
e3110c3897
12 files changed
+237
-63
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import sqlite3
|
||||
from module.category import Category
|
||||
|
||||
def GetAllCategories(db_name: str = 'pipe_store.db', parent_id: int = 1) -> list[Category]:
|
||||
conn = sqlite3.connect(db_name)
|
||||
conn.row_factory = sqlite3.Row
|
||||
cursor = conn.cursor()
|
||||
|
||||
categories = []
|
||||
|
||||
cursor.execute("SELECT id, name, description, image_path FROM categories WHERE parent_id = ?", [parent_id])
|
||||
|
||||
for row in cursor.fetchall():
|
||||
category = Category(
|
||||
id = row["id"],
|
||||
name = row["name"],
|
||||
description= row["description"],
|
||||
image_path= row["image_path"],
|
||||
)
|
||||
categories.append(category.model_dump())
|
||||
|
||||
conn.close()
|
||||
return categories
|
||||
@@ -0,0 +1,11 @@
|
||||
import sqlite3
|
||||
from module.product import Product
|
||||
|
||||
def get_products(db_name: str = 'pipe_store.db', parent_id: int = 1) -> List[Product]:
|
||||
conn = sqlite3.connect(db_name)
|
||||
conn.row_factory = sqlite3.Row
|
||||
transaction = conn.cursor()
|
||||
|
||||
products = []
|
||||
|
||||
transaction.execute("SELECT ... FROM products")
|
||||
Reference in new issue
Block a user