mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-30 09:39:20 -05:00
* ✨ Implement support for Pydantic's ORM mode * 🏗️ Re-structure/augment SQL tutorial source using ORM mode * 📝 Update SQL docs with SQLAlchemy, ORM mode, relationships * 🔥 Remove unused util in tutorial * 📝 Add tutorials for simple dict bodies and responses * 🔥 Remove old SQL tutorial * ✅ Add/update tests for SQL tutorial * ✅ Add tests for simple dicts (body and response) * 🐛 Fix cloning field from original field
14 lines
458 B
Python
14 lines
458 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
SQLALCHEMY_DATABASE_URI = "sqlite:///./test.db"
|
|
# SQLALCHEMY_DATABASE_URI = "postgresql://user:password@postgresserver/db"
|
|
|
|
engine = create_engine(
|
|
SQLALCHEMY_DATABASE_URI, connect_args={"check_same_thread": False}
|
|
)
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
Base = declarative_base()
|