Metadata-Version: 2.5
Name: dap-database
Version: 0.4.1
Summary: Shared SQLAlchemy engine + session factories for DAP (SQLite WAL / PostgreSQL)
Project-URL: Homepage, https://github.com/lagowski/dap
Project-URL: Repository, https://github.com/lagowski/dap
Project-URL: Issues, https://github.com/lagowski/dap/issues
Project-URL: Author — Rafał Łagowski, https://www.linkedin.com/in/rafallagowski/
Project-URL: Author — Daniel Łagowski, https://www.linkedin.com/in/daniellagowski/
Author: Rafał Łagowski, Daniel Łagowski
License: MIT
Keywords: database,postgresql,sqlalchemy,sqlite
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.13
Requires-Dist: sqlalchemy>=2.0.52
Description-Content-Type: text/markdown

# dap-database

Shared SQLAlchemy plumbing for DAP (#778 Phase 1). Import path: `dap_database`.

One home for the pieces previously duplicated between
`dap_engine.persistence.db` (sync) and `dap_engine.auth.db` (async):

- **URL/dialect helpers** — `detect_dialect`, `normalize_pg_prefix`,
  `pg_sync_url`, `pg_conn_string`, `redact_database_url`, `async_url_for`
- **Raw engine factories** — `create_sqlite_engine` (WAL pragmas, busy
  timeout), `create_postgresql_engine` (psycopg v3, pre-ping, recycle),
  `create_async_engine_for_url`
- **Session factories** — `make_session_factory`,
  `make_async_session_factory`, `session_scope`

## What deliberately stays out

- **ORM models and migrations** — schema ownership stays with the engine
  (`dap_engine.persistence`). The factories here create *no* tables.
- **DB drivers** — `aiosqlite` / `psycopg` are consumer dependencies;
  this package only requires `sqlalchemy`.

```python
from dap_database import create_sqlite_engine, make_session_factory, session_scope

engine = create_sqlite_engine("/data/state.db")
factory = make_session_factory(engine)
with session_scope(factory) as session:
    ...
```
