Initial commit.
This commit is contained in:
commit
2fa935016e
11 changed files with 1410 additions and 0 deletions
17
app/database.py
Normal file
17
app/database.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import sqlite3
|
||||
from pathlib import Path
|
||||
|
||||
DATABASE_PATH = Path(__file__).parent.parent / "data" / "reviews.db"
|
||||
|
||||
|
||||
def get_db():
|
||||
"""
|
||||
FastAPI dependency that provides a database connection.
|
||||
Yields a connection, then closes it when the request is done.
|
||||
"""
|
||||
conn = sqlite3.connect(DATABASE_PATH)
|
||||
conn.row_factory = sqlite3.Row
|
||||
try:
|
||||
yield conn
|
||||
finally:
|
||||
conn.close()
|
||||
Loading…
Add table
Add a link
Reference in a new issue