16 lines
418 B
Python
16 lines
418 B
Python
from sqlalchemy.orm import DeclarativeBase
|
|
from sqlalchemy import engine
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
pass
|
|
|
|
|
|
from sqlalchemy import event
|
|
|
|
@event.listens_for(engine.sync_engine, "connect")
|
|
def _enable_sqlite_fk(dbapi_connection, connection_record):
|
|
if settings.DATABASE_URL.startswith("sqlite"):
|
|
cursor = dbapi_connection.cursor()
|
|
cursor.execute("PRAGMA foreign_keys=ON")
|
|
cursor.close() |