final commit
This commit is contained in:
1 parent
0ffbba3bed
commit
7b242b8685
39 files changed
+5524
-65
No files matched your search
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
Database utilities for authentication.
|
||||
"""
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from .models import Base
|
||||
|
||||
|
||||
def utcnow():
|
||||
"""Return current UTC timestamp for database columns."""
|
||||
from datetime import datetime
|
||||
return datetime.utcnow()
|
||||
|
||||
|
||||
def get_db() -> Session:
|
||||
"""
|
||||
Dependency factory that yields a database session.
|
||||
|
||||
Should be imported and used with Depends(get_db) in endpoint functions.
|
||||
"""
|
||||
from db.session import SessionLocal
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
Reference in new issue
Block a user