diff options
| author | Tyler Hoang <tyler@tylerhoang.xyz> | 2026-05-08 01:58:48 -0700 |
|---|---|---|
| committer | Tyler Hoang <tyler@tylerhoang.xyz> | 2026-05-08 01:58:48 -0700 |
| commit | 2e0a94e88c847a5ed8dc6ad5fa49715cd631bdfe (patch) | |
| tree | 0c27fc5a8d8cbba60e571bb6690a13c0c0060ff4 /database.py | |
Initial commit — Commis personal chef app
AI-powered local chef tool: pantry tracking, meal logging, rotating weekly
menu generation, and grocery list optimization via Ollama (llama3).
FastAPI backend, SQLite, vanilla JS frontend.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'database.py')
| -rw-r--r-- | database.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/database.py b/database.py new file mode 100644 index 0000000..aab1d4f --- /dev/null +++ b/database.py @@ -0,0 +1,20 @@ +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker, declarative_base +from config import settings + +engine = create_engine( + settings.database_url, + connect_args={"check_same_thread": False} +) + +SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) + +Base = declarative_base() + + +def get_db(): + db = SessionLocal() + try: + yield db + finally: + db.close() |
