feat(modefied)

This commit is contained in:
Black_Raven committed 2026-03-17 12:08:19 +03:00
1 parent d705f2f9d3
commit e3110c3897
12 files changed
+237 -63

No files matched your search

+23
View File
@@ -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