CRUDKit update.

This commit is contained in:
Yaro Kasear 2025-09-08 11:56:29 -05:00
parent de29d45106
commit f1fa1f2407
8 changed files with 391 additions and 44 deletions

14
crudkit/_sqlite.py Normal file
View file

@ -0,0 +1,14 @@
from __future__ import annotations
from sqlalchemy import event
from sqlalchemy.engine import Engine
def apply_sqlite_pragmas(engine: Engine, pragmas: dict[str, str]) -> None:
if not str(engine.url).startswith("sqlite://"):
return
@event.listens_for(engine, "connect")
def set_sqlite_pragma(dbapi_connection, connection_record):
cursor = dbapi_connection.cursor()
for key, value in pragmas.items():
cursor.execute(f"PRAGMA {key}={value}")
cursor.close()