HeshamTB
b0dc22070e
- Classes in models describe tables in database - Classes in schemas desribe pydantic models to read from the API. - database provides a connection and sessions to the database. - crud exposes the interface to the database, i.e. actions we can take from the application onto the database Signed-off-by: HeshamTB <hishaminv@gmail.com>
15 lines
474 B
Python
15 lines
474 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db"
|
|
# SQLALCHEMY_DATABASE_URL = "postgresql://user:password@postgresserver/db"
|
|
|
|
# For sqlite
|
|
engine = create_engine(
|
|
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
|
|
)
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
Base = declarative_base()
|