Loginauth / database.py
Gregniuki's picture
Update database.py
4e62874
raw
history blame
535 Bytes
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from models import Base
DATABASE_URL = "sqlite:///./test.db" # Update this with your database URL
engine = create_engine(DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
# Function to get a user by email
def get_user_by_email(db, email):
return db.query(models.User).filter(models.User.email == email).first()