munch-ease-backend/db.py

48 lines
933 B
Python
Raw Normal View History

2025-10-18 03:26:42 +00:00
import asyncio
2024-01-08 00:38:17 +00:00
import aiosqlite
2025-10-18 03:26:42 +00:00
async def connect(path="./data/doof.sqlite") -> aiosqlite.Connection:
2024-04-25 04:57:39 +00:00
return await aiosqlite.connect(path)
2024-01-08 00:38:17 +00:00
2025-10-18 03:26:42 +00:00
2024-04-25 04:57:39 +00:00
async def create(conn: aiosqlite.Connection):
2024-01-13 07:44:48 +00:00
import products.db as product_db
2025-10-18 03:26:42 +00:00
2024-01-13 01:54:04 +00:00
await product_db.create(conn)
2024-01-13 03:21:38 +00:00
2024-01-17 07:21:16 +00:00
import ingredients.db as ingredient_db
2025-10-18 03:26:42 +00:00
2024-01-17 07:21:16 +00:00
await ingredient_db.create(conn)
2024-01-13 07:44:48 +00:00
import recipes.db as recipe_db
2025-10-18 03:26:42 +00:00
2024-01-13 03:21:38 +00:00
await recipe_db.create(conn)
2024-01-13 07:44:48 +00:00
import persons.db as person_db
2025-10-18 03:26:42 +00:00
2024-01-13 07:18:25 +00:00
await person_db.create(conn)
import meals.db as meals_db
2025-10-18 03:26:42 +00:00
2024-05-17 09:09:03 +00:00
await meals_db.create(conn)
2025-10-18 03:26:42 +00:00
2024-05-17 09:09:03 +00:00
import shopping.db as shopping_db
2025-10-18 03:26:42 +00:00
2024-05-18 07:05:01 +00:00
await shopping_db.create(conn)
2025-10-18 03:26:42 +00:00
if __name__ == "__main__":
2024-05-18 07:05:01 +00:00
from tests.test_data import create_test_data
async def main():
conn = await connect()
await create(conn)
await conn.commit()
await create_test_data(conn)
await conn.commit()
await conn.close()
2025-10-18 03:26:42 +00:00
asyncio.run(main())