prefect server in zig
1# python prefect server database reference
2
3reference documentation for understanding how the Python prefect server implements its database layer. useful for ensuring our Zig implementation stores data compatibly.
4
5## contents
6
7- [architecture.md](./architecture.md) - overall structure, abstraction layers, backend selection
8- [orm-models.md](./orm-models.md) - SQLAlchemy models, relationships, custom types
9- [migrations.md](./migrations.md) - alembic setup, dialect-specific migrations
10- [query-patterns.md](./query-patterns.md) - dialect differences, transaction handling, connection pooling
11- [zig-compat-notes.md](./zig-compat-notes.md) - comparison with our zig implementation, gaps to address
12
13## key insight
14
15the Python implementation uses a three-tier abstraction:
16
171. **DatabaseConfiguration** - connection/engine management (AsyncPostgresConfiguration, AioSqliteConfiguration)
182. **QueryComponents** - dialect-specific SQL generation (json handling, time series, updates)
193. **ORMConfiguration** - migration paths, upsert columns
20
21this allows the same codebase to work with both SQLite and PostgreSQL by swapping implementations at runtime based on connection URL.
22
23## source location
24
25```
26~/github.com/prefecthq/prefect/src/prefect/server/database/
27```