narabi-orm 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. narabi_orm-0.1.0/.github/workflows/examples.yml +43 -0
  2. narabi_orm-0.1.0/.github/workflows/publish.yml +82 -0
  3. narabi_orm-0.1.0/.github/workflows/tests.yml +158 -0
  4. narabi_orm-0.1.0/.gitignore +6 -0
  5. narabi_orm-0.1.0/AGENTS.md +10 -0
  6. narabi_orm-0.1.0/CONTRIBUTING.md +26 -0
  7. narabi_orm-0.1.0/LICENSE +29 -0
  8. narabi_orm-0.1.0/PITCH.md +19 -0
  9. narabi_orm-0.1.0/PKG-INFO +104 -0
  10. narabi_orm-0.1.0/README.md +65 -0
  11. narabi_orm-0.1.0/docs/README.md +12 -0
  12. narabi_orm-0.1.0/docs/architecture.md +48 -0
  13. narabi_orm-0.1.0/docs/comparisons.md +92 -0
  14. narabi_orm-0.1.0/docs/fastapi.md +92 -0
  15. narabi_orm-0.1.0/docs/flask.md +52 -0
  16. narabi_orm-0.1.0/docs/guides.md +206 -0
  17. narabi_orm-0.1.0/docs/reference.md +813 -0
  18. narabi_orm-0.1.0/docs/tutorial/01-setup.md +21 -0
  19. narabi_orm-0.1.0/docs/tutorial/02-models-and-naming.md +36 -0
  20. narabi_orm-0.1.0/docs/tutorial/03-first-book.md +71 -0
  21. narabi_orm-0.1.0/docs/tutorial/04-queries.md +41 -0
  22. narabi_orm-0.1.0/docs/tutorial/05-authors.md +135 -0
  23. narabi_orm-0.1.0/docs/tutorial/06-orders.md +59 -0
  24. narabi_orm-0.1.0/docs/tutorial/07-privacy.md +51 -0
  25. narabi_orm-0.1.0/docs/tutorial/08-console.md +35 -0
  26. narabi_orm-0.1.0/docs/tutorial.md +16 -0
  27. narabi_orm-0.1.0/examples/README.md +126 -0
  28. narabi_orm-0.1.0/examples/domain/library_lending/README.md +85 -0
  29. narabi_orm-0.1.0/examples/domain/library_lending/app.py +121 -0
  30. narabi_orm-0.1.0/examples/domain/library_lending/catalog_locations.py +11 -0
  31. narabi_orm-0.1.0/examples/domain/library_lending/initial_migration.py +32 -0
  32. narabi_orm-0.1.0/examples/domain/library_lending/postgresql.py +28 -0
  33. narabi_orm-0.1.0/examples/domain/library_lending/pyproject.toml +20 -0
  34. narabi_orm-0.1.0/examples/domain/maintenance_api/README.md +116 -0
  35. narabi_orm-0.1.0/examples/domain/maintenance_api/app.py +133 -0
  36. narabi_orm-0.1.0/examples/domain/maintenance_api/demo.py +46 -0
  37. narabi_orm-0.1.0/examples/domain/maintenance_api/pyproject.toml +18 -0
  38. narabi_orm-0.1.0/examples/domain/order_import/README.md +19 -0
  39. narabi_orm-0.1.0/examples/domain/order_import/app.py +99 -0
  40. narabi_orm-0.1.0/examples/domain/order_import/pyproject.toml +14 -0
  41. narabi_orm-0.1.0/examples/features/_support.py +97 -0
  42. narabi_orm-0.1.0/examples/features/aggregates/README.md +12 -0
  43. narabi_orm-0.1.0/examples/features/aggregates/app.py +23 -0
  44. narabi_orm-0.1.0/examples/features/async_console/README.md +17 -0
  45. narabi_orm-0.1.0/examples/features/async_console/app.py +18 -0
  46. narabi_orm-0.1.0/examples/features/async_console/migrations/000001_initial.py +8 -0
  47. narabi_orm-0.1.0/examples/features/async_console/models.py +7 -0
  48. narabi_orm-0.1.0/examples/features/async_console/pyproject.toml +19 -0
  49. narabi_orm-0.1.0/examples/features/async_console/seed_data.py +5 -0
  50. narabi_orm-0.1.0/examples/features/change_tracking/README.md +12 -0
  51. narabi_orm-0.1.0/examples/features/change_tracking/app.py +26 -0
  52. narabi_orm-0.1.0/examples/features/database_configuration/README.md +17 -0
  53. narabi_orm-0.1.0/examples/features/database_configuration/app.py +34 -0
  54. narabi_orm-0.1.0/examples/features/defaults/README.md +12 -0
  55. narabi_orm-0.1.0/examples/features/defaults/app.py +29 -0
  56. narabi_orm-0.1.0/examples/features/diagnostics/README.md +17 -0
  57. narabi_orm-0.1.0/examples/features/diagnostics/app.py +19 -0
  58. narabi_orm-0.1.0/examples/features/diagnostics/migrations/000001_initial.py +8 -0
  59. narabi_orm-0.1.0/examples/features/diagnostics/models.py +7 -0
  60. narabi_orm-0.1.0/examples/features/diagnostics/pyproject.toml +18 -0
  61. narabi_orm-0.1.0/examples/features/eager_loading/README.md +12 -0
  62. narabi_orm-0.1.0/examples/features/eager_loading/app.py +23 -0
  63. narabi_orm-0.1.0/examples/features/filtering/README.md +12 -0
  64. narabi_orm-0.1.0/examples/features/filtering/app.py +18 -0
  65. narabi_orm-0.1.0/examples/features/historical_data/README.md +12 -0
  66. narabi_orm-0.1.0/examples/features/historical_data/app.py +26 -0
  67. narabi_orm-0.1.0/examples/features/historical_data/initial.py +37 -0
  68. narabi_orm-0.1.0/examples/features/lifecycle_hooks/README.md +12 -0
  69. narabi_orm-0.1.0/examples/features/lifecycle_hooks/app.py +46 -0
  70. narabi_orm-0.1.0/examples/features/migration_apply/README.md +17 -0
  71. narabi_orm-0.1.0/examples/features/migration_apply/app.py +19 -0
  72. narabi_orm-0.1.0/examples/features/migration_apply/migrations/000001_initial.py +8 -0
  73. narabi_orm-0.1.0/examples/features/migration_apply/models.py +7 -0
  74. narabi_orm-0.1.0/examples/features/migration_apply/pyproject.toml +18 -0
  75. narabi_orm-0.1.0/examples/features/migration_generation/README.md +17 -0
  76. narabi_orm-0.1.0/examples/features/migration_generation/app.py +20 -0
  77. narabi_orm-0.1.0/examples/features/migration_generation/migrations/000001_initial.py +8 -0
  78. narabi_orm-0.1.0/examples/features/migration_generation/models.py +8 -0
  79. narabi_orm-0.1.0/examples/features/migration_generation/pyproject.toml +18 -0
  80. narabi_orm-0.1.0/examples/features/migration_rollback/README.md +17 -0
  81. narabi_orm-0.1.0/examples/features/migration_rollback/app.py +21 -0
  82. narabi_orm-0.1.0/examples/features/migration_rollback/migrations/000001_initial.py +8 -0
  83. narabi_orm-0.1.0/examples/features/migration_rollback/migrations/000002_add_note.py +7 -0
  84. narabi_orm-0.1.0/examples/features/migration_rollback/models.py +8 -0
  85. narabi_orm-0.1.0/examples/features/migration_rollback/pyproject.toml +19 -0
  86. narabi_orm-0.1.0/examples/features/migration_rollback/seed_data.py +5 -0
  87. narabi_orm-0.1.0/examples/features/migration_safety/README.md +19 -0
  88. narabi_orm-0.1.0/examples/features/migration_safety/app.py +32 -0
  89. narabi_orm-0.1.0/examples/features/migration_safety/migrations/000001_initial.py +8 -0
  90. narabi_orm-0.1.0/examples/features/migration_safety/models.py +7 -0
  91. narabi_orm-0.1.0/examples/features/migration_safety/pyproject.toml +18 -0
  92. narabi_orm-0.1.0/examples/features/migration_safety/review/000002_drop.py +6 -0
  93. narabi_orm-0.1.0/examples/features/offline_replay/README.md +17 -0
  94. narabi_orm-0.1.0/examples/features/offline_replay/app.py +16 -0
  95. narabi_orm-0.1.0/examples/features/offline_replay/migrations/000001_initial.py +8 -0
  96. narabi_orm-0.1.0/examples/features/offline_replay/models.py +7 -0
  97. narabi_orm-0.1.0/examples/features/offline_replay/pyproject.toml +18 -0
  98. narabi_orm-0.1.0/examples/features/pagination/README.md +12 -0
  99. narabi_orm-0.1.0/examples/features/pagination/app.py +18 -0
  100. narabi_orm-0.1.0/examples/features/persistence/README.md +12 -0
  101. narabi_orm-0.1.0/examples/features/persistence/app.py +30 -0
  102. narabi_orm-0.1.0/examples/features/privacy/README.md +12 -0
  103. narabi_orm-0.1.0/examples/features/privacy/app.py +26 -0
  104. narabi_orm-0.1.0/examples/features/privacy_inventory/README.md +17 -0
  105. narabi_orm-0.1.0/examples/features/privacy_inventory/app.py +16 -0
  106. narabi_orm-0.1.0/examples/features/privacy_inventory/models.py +7 -0
  107. narabi_orm-0.1.0/examples/features/privacy_inventory/pyproject.toml +18 -0
  108. narabi_orm-0.1.0/examples/features/pytest_fixture/README.md +15 -0
  109. narabi_orm-0.1.0/examples/features/pytest_fixture/app.py +17 -0
  110. narabi_orm-0.1.0/examples/features/pytest_fixture/fixture_demo.py +13 -0
  111. narabi_orm-0.1.0/examples/features/query_projection/README.md +12 -0
  112. narabi_orm-0.1.0/examples/features/query_projection/app.py +27 -0
  113. narabi_orm-0.1.0/examples/features/relationships/README.md +12 -0
  114. narabi_orm-0.1.0/examples/features/relationships/app.py +21 -0
  115. narabi_orm-0.1.0/examples/features/schema_drift/README.md +17 -0
  116. narabi_orm-0.1.0/examples/features/schema_drift/app.py +21 -0
  117. narabi_orm-0.1.0/examples/features/schema_drift/migrations/000001_initial.py +8 -0
  118. narabi_orm-0.1.0/examples/features/schema_drift/models.py +7 -0
  119. narabi_orm-0.1.0/examples/features/schema_drift/pyproject.toml +18 -0
  120. narabi_orm-0.1.0/examples/features/scopes/README.md +12 -0
  121. narabi_orm-0.1.0/examples/features/scopes/app.py +19 -0
  122. narabi_orm-0.1.0/examples/features/seeding/README.md +17 -0
  123. narabi_orm-0.1.0/examples/features/seeding/app.py +20 -0
  124. narabi_orm-0.1.0/examples/features/seeding/migrations/000001_initial.py +8 -0
  125. narabi_orm-0.1.0/examples/features/seeding/models.py +7 -0
  126. narabi_orm-0.1.0/examples/features/seeding/pyproject.toml +19 -0
  127. narabi_orm-0.1.0/examples/features/seeding/seed_data.py +5 -0
  128. narabi_orm-0.1.0/examples/features/serialization/README.md +12 -0
  129. narabi_orm-0.1.0/examples/features/serialization/app.py +31 -0
  130. narabi_orm-0.1.0/examples/features/soft_deletion/README.md +12 -0
  131. narabi_orm-0.1.0/examples/features/soft_deletion/app.py +32 -0
  132. narabi_orm-0.1.0/examples/features/timestamps/README.md +12 -0
  133. narabi_orm-0.1.0/examples/features/timestamps/app.py +31 -0
  134. narabi_orm-0.1.0/examples/features/transactions/README.md +12 -0
  135. narabi_orm-0.1.0/examples/features/transactions/app.py +31 -0
  136. narabi_orm-0.1.0/examples/features/typing_stubs/README.md +17 -0
  137. narabi_orm-0.1.0/examples/features/typing_stubs/app.py +16 -0
  138. narabi_orm-0.1.0/examples/features/typing_stubs/models.py +7 -0
  139. narabi_orm-0.1.0/examples/features/typing_stubs/pyproject.toml +18 -0
  140. narabi_orm-0.1.0/examples/features/validation/README.md +12 -0
  141. narabi_orm-0.1.0/examples/features/validation/app.py +39 -0
  142. narabi_orm-0.1.0/examples/toml_schema/app.py +42 -0
  143. narabi_orm-0.1.0/examples/toml_schema/demo.py +40 -0
  144. narabi_orm-0.1.0/examples/toml_schema/schema.toml +16 -0
  145. narabi_orm-0.1.0/narabi/__init__.py +27 -0
  146. narabi_orm-0.1.0/narabi/__main__.py +5 -0
  147. narabi_orm-0.1.0/narabi/cli.py +338 -0
  148. narabi_orm-0.1.0/narabi/console.py +102 -0
  149. narabi_orm-0.1.0/narabi/database.py +310 -0
  150. narabi_orm-0.1.0/narabi/fields/__init__.py +13 -0
  151. narabi_orm-0.1.0/narabi/fields/defaults.py +59 -0
  152. narabi_orm-0.1.0/narabi/fields/markers.py +74 -0
  153. narabi_orm-0.1.0/narabi/migrations/__init__.py +22 -0
  154. narabi_orm-0.1.0/narabi/migrations/bootstrap.py +30 -0
  155. narabi_orm-0.1.0/narabi/migrations/decorators.py +22 -0
  156. narabi_orm-0.1.0/narabi/migrations/diff.py +96 -0
  157. narabi_orm-0.1.0/narabi/migrations/dsl.py +255 -0
  158. narabi_orm-0.1.0/narabi/migrations/errors.py +5 -0
  159. narabi_orm-0.1.0/narabi/migrations/executor.py +299 -0
  160. narabi_orm-0.1.0/narabi/migrations/generate.py +149 -0
  161. narabi_orm-0.1.0/narabi/migrations/historical.py +158 -0
  162. narabi_orm-0.1.0/narabi/migrations/history.py +160 -0
  163. narabi_orm-0.1.0/narabi/migrations/models.py +57 -0
  164. narabi_orm-0.1.0/narabi/migrations/postgres_executor.py +239 -0
  165. narabi_orm-0.1.0/narabi/migrations/postgresql.py +268 -0
  166. narabi_orm-0.1.0/narabi/migrations/preview.py +150 -0
  167. narabi_orm-0.1.0/narabi/migrations/replay.py +40 -0
  168. narabi_orm-0.1.0/narabi/migrations/reverse.py +127 -0
  169. narabi_orm-0.1.0/narabi/migrations/schema.py +169 -0
  170. narabi_orm-0.1.0/narabi/migrations/snapshot.py +52 -0
  171. narabi_orm-0.1.0/narabi/migrations/sqlite.py +131 -0
  172. narabi_orm-0.1.0/narabi/models/__init__.py +1 -0
  173. narabi_orm-0.1.0/narabi/models/bulk.py +123 -0
  174. narabi_orm-0.1.0/narabi/models/core.py +440 -0
  175. narabi_orm-0.1.0/narabi/models/inflection.py +37 -0
  176. narabi_orm-0.1.0/narabi/models/lifecycle.py +125 -0
  177. narabi_orm-0.1.0/narabi/models/privacy.py +19 -0
  178. narabi_orm-0.1.0/narabi/models/serialization.py +145 -0
  179. narabi_orm-0.1.0/narabi/models/soft_delete.py +59 -0
  180. narabi_orm-0.1.0/narabi/models/timestamps.py +47 -0
  181. narabi_orm-0.1.0/narabi/models/validation.py +149 -0
  182. narabi_orm-0.1.0/narabi/models/values.py +167 -0
  183. narabi_orm-0.1.0/narabi/project.py +108 -0
  184. narabi_orm-0.1.0/narabi/py.typed +0 -0
  185. narabi_orm-0.1.0/narabi/pytest.py +11 -0
  186. narabi_orm-0.1.0/narabi/query/__init__.py +7 -0
  187. narabi_orm-0.1.0/narabi/query/expressions.py +180 -0
  188. narabi_orm-0.1.0/narabi/query/relation.py +562 -0
  189. narabi_orm-0.1.0/narabi/query/scopes.py +36 -0
  190. narabi_orm-0.1.0/narabi/relations/__init__.py +6 -0
  191. narabi_orm-0.1.0/narabi/relations/prefetch.py +66 -0
  192. narabi_orm-0.1.0/narabi/relations/references.py +196 -0
  193. narabi_orm-0.1.0/narabi/relations/relationships.py +185 -0
  194. narabi_orm-0.1.0/narabi/schema.py +132 -0
  195. narabi_orm-0.1.0/narabi/stubs.py +275 -0
  196. narabi_orm-0.1.0/narabi.toml +7 -0
  197. narabi_orm-0.1.0/pyproject.toml +44 -0
  198. narabi_orm-0.1.0/tests/feasibility/README.md +44 -0
  199. narabi_orm-0.1.0/tests/feasibility/__init__.py +0 -0
  200. narabi_orm-0.1.0/tests/feasibility/check_typing.py +138 -0
  201. narabi_orm-0.1.0/tests/feasibility/models.py +21 -0
  202. narabi_orm-0.1.0/tests/feasibility/prototype.py +162 -0
  203. narabi_orm-0.1.0/tests/feasibility/test_runtime.py +87 -0
  204. narabi_orm-0.1.0/tests/test_bulk.py +141 -0
  205. narabi_orm-0.1.0/tests/test_cli.py +85 -0
  206. narabi_orm-0.1.0/tests/test_console.py +44 -0
  207. narabi_orm-0.1.0/tests/test_defaults.py +57 -0
  208. narabi_orm-0.1.0/tests/test_fastapi_guide.py +82 -0
  209. narabi_orm-0.1.0/tests/test_feature_examples.py +29 -0
  210. narabi_orm-0.1.0/tests/test_integration.py +368 -0
  211. narabi_orm-0.1.0/tests/test_library_migration.py +49 -0
  212. narabi_orm-0.1.0/tests/test_lifecycle.py +250 -0
  213. narabi_orm-0.1.0/tests/test_migration_data.py +187 -0
  214. narabi_orm-0.1.0/tests/test_migration_diff.py +76 -0
  215. narabi_orm-0.1.0/tests/test_migration_drift.py +55 -0
  216. narabi_orm-0.1.0/tests/test_migration_dsl.py +174 -0
  217. narabi_orm-0.1.0/tests/test_migration_executor.py +166 -0
  218. narabi_orm-0.1.0/tests/test_migration_generation.py +103 -0
  219. narabi_orm-0.1.0/tests/test_migration_history.py +129 -0
  220. narabi_orm-0.1.0/tests/test_migration_locking.py +29 -0
  221. narabi_orm-0.1.0/tests/test_migration_replay.py +117 -0
  222. narabi_orm-0.1.0/tests/test_migration_rollback.py +196 -0
  223. narabi_orm-0.1.0/tests/test_migration_schema.py +75 -0
  224. narabi_orm-0.1.0/tests/test_persistence_state.py +134 -0
  225. narabi_orm-0.1.0/tests/test_postgresql_drift.py +169 -0
  226. narabi_orm-0.1.0/tests/test_postgresql_executor.py +114 -0
  227. narabi_orm-0.1.0/tests/test_postgresql_migrations.py +40 -0
  228. narabi_orm-0.1.0/tests/test_postgresql_pool.py +81 -0
  229. narabi_orm-0.1.0/tests/test_privacy.py +48 -0
  230. narabi_orm-0.1.0/tests/test_records.py +49 -0
  231. narabi_orm-0.1.0/tests/test_references.py +227 -0
  232. narabi_orm-0.1.0/tests/test_relations.py +240 -0
  233. narabi_orm-0.1.0/tests/test_schema_bootstrap.py +73 -0
  234. narabi_orm-0.1.0/tests/test_serialization.py +64 -0
  235. narabi_orm-0.1.0/tests/test_soft_delete.py +133 -0
  236. narabi_orm-0.1.0/tests/test_stubs.py +173 -0
  237. narabi_orm-0.1.0/tests/test_transactions.py +156 -0
  238. narabi_orm-0.1.0/tests/test_validation.py +93 -0
  239. narabi_orm-0.1.0/tests/test_values.py +157 -0
  240. narabi_orm-0.1.0/uv.lock +830 -0
@@ -0,0 +1,43 @@
1
+ name: Examples
2
+
3
+ on:
4
+ workflow_call:
5
+ workflow_dispatch:
6
+ pull_request:
7
+ paths:
8
+ - examples/**
9
+ - narabi/**
10
+ - pyproject.toml
11
+ - uv.lock
12
+ - .github/workflows/examples.yml
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ jobs:
18
+ examples:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: '3.12'
25
+ - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
26
+ - run: uv sync --locked --no-install-project --extra test --group examples
27
+ - name: Library lending
28
+ run: uv run --no-sync python -m examples.domain.library_lending.app
29
+ - name: Supplier order import
30
+ run: uv run --no-sync python -m examples.domain.order_import.app
31
+ - name: Maintenance ticket API
32
+ run: uv run --no-sync python -m examples.domain.maintenance_api.demo
33
+ - name: TOML schema quickstart
34
+ run: uv run --no-sync python -m examples.toml_schema.demo
35
+ - name: Feature demos
36
+ run: |
37
+ for demo in examples/features/*/app.py; do
38
+ module="${demo%.py}"
39
+ echo "::group::$module"
40
+ sed -n '3p' "${demo%/app.py}/README.md"
41
+ uv run --no-sync python -m "${module//\//.}"
42
+ echo "::endgroup::"
43
+ done
@@ -0,0 +1,82 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+
12
+ tests:
13
+ uses: ./.github/workflows/tests.yml
14
+
15
+ examples:
16
+ uses: ./.github/workflows/examples.yml
17
+
18
+ build:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v6
22
+ with:
23
+ persist-credentials: false
24
+
25
+ - uses: actions/setup-python@v6
26
+ with:
27
+ python-version: '3.12'
28
+
29
+ - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
30
+
31
+ - name: Validate release version
32
+ run: |
33
+ python - <<'PY'
34
+ import os
35
+ import tomllib
36
+ from pathlib import Path
37
+
38
+ version = tomllib.loads(Path('pyproject.toml').read_text())['project']['version']
39
+ tag = os.environ['GITHUB_REF_NAME']
40
+ if tag != f'v{version}':
41
+ raise SystemExit(f'Release tag {tag} must match v{version}')
42
+ PY
43
+
44
+ - name: Build distributions
45
+ run: uv build --no-sources
46
+
47
+ - name: Check distributions
48
+ run: uvx twine check dist/*
49
+
50
+ - name: Smoke-test installed wheel
51
+ run: |
52
+ uv venv --python 3.12 "$RUNNER_TEMP/narabi-smoke"
53
+ uv pip install --python "$RUNNER_TEMP/narabi-smoke/bin/python" dist/*.whl
54
+ cd "$RUNNER_TEMP"
55
+ narabi_bin="$RUNNER_TEMP/narabi-smoke/bin"
56
+ "$narabi_bin/python" -c 'import narabi'
57
+ "$narabi_bin/narabi" --help
58
+
59
+ - uses: actions/upload-artifact@v5
60
+ with:
61
+ name: distributions
62
+ path: dist/
63
+ if-no-files-found: error
64
+
65
+ publish:
66
+ needs: build
67
+ runs-on: ubuntu-latest
68
+
69
+ environment:
70
+ name: PyPI
71
+ url: https://pypi.org/project/narabi-orm/
72
+
73
+ permissions:
74
+ id-token: write
75
+
76
+ steps:
77
+ - uses: actions/download-artifact@v6
78
+ with:
79
+ name: distributions
80
+ path: dist/
81
+
82
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,158 @@
1
+ name: Tests
2
+
3
+ on: [push, pull_request, workflow_call]
4
+
5
+ jobs:
6
+ installed-wheel:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ extra: [core, sqlite, postgres, console, all]
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: '3.12'
16
+ - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
17
+ - name: Build, install, and smoke-test the wheel
18
+ shell: bash
19
+ env:
20
+ NARABI_WHEEL_EXTRA: ${{ matrix.extra }}
21
+ run: |
22
+ smoke_dir="$(mktemp -d)"
23
+ uv build --wheel --out-dir "$smoke_dir/dist"
24
+ wheels=("$smoke_dir"/dist/*.whl)
25
+
26
+ cd "$smoke_dir"
27
+ unset PYTHONPATH
28
+ uv venv --python 3.12 .venv
29
+ wheel="${wheels[0]}"
30
+ if [[ "$NARABI_WHEEL_EXTRA" != core ]]; then
31
+ wheel+="[$NARABI_WHEEL_EXTRA]"
32
+ fi
33
+ uv pip install --python .venv/bin/python "$wheel"
34
+ .venv/bin/narabi --help
35
+ .venv/bin/narabi init
36
+ .venv/bin/narabi migration create smoke
37
+ .venv/bin/narabi schema
38
+ .venv/bin/narabi privacy inventory
39
+ .venv/bin/python - <<'PY'
40
+ import asyncio
41
+ from importlib.util import find_spec
42
+ import os
43
+ from pathlib import Path
44
+
45
+ import subprocess
46
+ import sys
47
+
48
+ import narabi
49
+
50
+ extra = os.environ["NARABI_WHEEL_EXTRA"]
51
+ has_sqlite = extra in {"sqlite", "all"}
52
+ has_postgres = extra in {"postgres", "all"}
53
+ for module, installed in (
54
+ ("aiosqlite", has_sqlite),
55
+ ("psycopg", has_postgres),
56
+ ("psycopg_pool", has_postgres),
57
+ ("IPython", extra in {"console", "all"}),
58
+ ):
59
+ assert module not in sys.modules
60
+ assert (find_spec(module) is not None) == installed
61
+
62
+ @narabi.table(name="entries")
63
+ class Entry:
64
+ id: narabi.Primary[int] = narabi.Increment()
65
+ title: str
66
+
67
+ async def smoke():
68
+ db = narabi.Database("sqlite", Path("smoke.sqlite3"))
69
+ await db.execute("CREATE TABLE entries (id INTEGER PRIMARY KEY, title TEXT NOT NULL)")
70
+ entry = await Entry.create(title="installed wheel", db=db)
71
+ loaded = await Entry.require(entry.id, db=db)
72
+ assert loaded.title == "installed wheel"
73
+
74
+ async def verify_missing_extra(database, extra, operation):
75
+ try:
76
+ await operation(database)
77
+ except RuntimeError as error:
78
+ assert f"narabi-orm[{extra}]" in str(error), error
79
+ else:
80
+ raise AssertionError(f"Expected an install hint for {extra}")
81
+
82
+ if not has_sqlite:
83
+ result = subprocess.run(
84
+ [sys.executable, "-m", "narabi", "doctor"], capture_output=True, text=True,
85
+ )
86
+ assert result.returncode == 1, result
87
+ assert "narabi-orm[sqlite]" in result.stderr, result.stderr
88
+
89
+ console = subprocess.run(
90
+ [sys.executable, "-m", "narabi", "console"],
91
+ input='print("console-models", len(models()))\n',
92
+ capture_output=True, text=True,
93
+ env={**os.environ, "IPYTHONDIR": str(Path.cwd() / "ipython")},
94
+ )
95
+ if extra in {"console", "all"}:
96
+ assert console.returncode == 0, console.stderr
97
+ assert "console-models 1" in console.stdout, console.stdout
98
+ else:
99
+ assert console.returncode == 1, console
100
+ assert "narabi-orm[console]" in console.stderr, console.stderr
101
+
102
+ async def check():
103
+ if has_sqlite:
104
+ await smoke()
105
+ else:
106
+ await verify_missing_extra(
107
+ narabi.Database("sqlite", ":memory:"), "sqlite",
108
+ lambda db: db.execute("SELECT 1"),
109
+ )
110
+ if not has_postgres:
111
+ await verify_missing_extra(
112
+ narabi.Database("postgresql", ""), "postgres",
113
+ lambda db: db.execute("SELECT 1"),
114
+ )
115
+ await verify_missing_extra(
116
+ narabi.Database("postgresql", "", pool=True), "postgres",
117
+ lambda db: db.open(),
118
+ )
119
+
120
+ asyncio.run(check())
121
+ PY
122
+
123
+ integration:
124
+ runs-on: ubuntu-latest
125
+ services:
126
+ postgres:
127
+ image: postgres:16
128
+ env:
129
+ POSTGRES_USER: narabi
130
+ POSTGRES_PASSWORD: narabi
131
+ POSTGRES_DB: narabi_test
132
+ ports:
133
+ - 5432:5432
134
+ options: >-
135
+ --health-cmd "pg_isready -U narabi -d narabi_test"
136
+ --health-interval 5s
137
+ --health-timeout 5s
138
+ --health-retries 10
139
+ env:
140
+ NARABI_TEST_POSTGRES: postgresql://narabi:narabi@localhost:5432/narabi_test
141
+ steps:
142
+ - uses: actions/checkout@v4
143
+ - uses: actions/setup-python@v5
144
+ with:
145
+ python-version: '3.12'
146
+ - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
147
+ - run: uv sync --locked --no-install-project --extra postgres --extra test --group examples
148
+ - run: uv run --no-sync python -m narabi --help
149
+ - name: Replay the library schema from source
150
+ working-directory: examples/domain/library_lending
151
+ run: PYTHONPATH="$GITHUB_WORKSPACE" uv run --project ../../.. --no-sync python -m narabi schema --dialect sqlite
152
+ - run: uv run --no-sync --with pyright==1.1.408 python -m unittest discover -s tests -v
153
+ - name: Run the PostgreSQL library example
154
+ env:
155
+ DATABASE_URL: postgresql://narabi:narabi@localhost:5432/narabi_demo
156
+ run: |
157
+ docker exec "${{ job.services.postgres.id }}" createdb -U narabi narabi_demo
158
+ uv run --no-sync python -m examples.domain.library_lending.postgresql
@@ -0,0 +1,6 @@
1
+ __pycache__/
2
+ *.sqlite3
3
+ .venv/
4
+ dist/
5
+
6
+ ROADMAP.md
@@ -0,0 +1,10 @@
1
+ # Working on Narabi
2
+
3
+ - Use **Narabi** for the project, `narabi` for the import and CLI, and `narabi-orm` for the distribution. Support standalone `narabi.toml` and `[tool.narabi]` in `pyproject.toml` as peer choices.
4
+ - Keep models, queries, migrations, and privacy in core. SQLite, PostgreSQL, and IPython are optional. Load their dependencies at the point of use and keep clean-wheel checks current.
5
+ - Prefer readable code that earns its place. Reuse existing behavior, keep transaction boundaries explicit, and avoid adding abstractions for hypothetical callers.
6
+ - Use Python and `uv`. Teach project setup with `uv add` and `uv run`. Use the PyPI distribution in user-facing setup and reserve checkout instructions for contributors and repository examples. Let Narabi select the configured database unless an example needs an explicit handle. Read the manifest and CI workflows before changing commands. Test through the same public entry point that exposed the problem and run the applicable backend checks.
7
+ - Keep the README a showcase. Teach with runnable, progressive examples in `docs/`, following the Rails Guides approach. Describe tradeoffs with other libraries respectfully and verify capability claims.
8
+ - When asked to commit, keep commits atomic and match recent subjects. Use `gh` for requested GitHub work. When asked to fix or monitor CI, follow the relevant checks through completion and report which ones passed or remain blocked.
9
+
10
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, architecture, and verification commands.
@@ -0,0 +1,26 @@
1
+ # Contributing to Narabi
2
+
3
+ ## Set up the checkout
4
+
5
+ Use Python 3.12 or newer and `uv`.
6
+
7
+ ```sh
8
+ uv sync --locked --no-install-project --extra test --group examples
9
+ uv run --no-sync --with pyright==1.1.408 python -m unittest discover -s tests -v
10
+ ```
11
+
12
+ Run a focused suite while iterating, for example `uv run --no-sync python -m unittest discover -s tests -p test_transactions.py -v`. Add `--extra postgres` to synchronization and set `NARABI_TEST_POSTGRES` to a disposable PostgreSQL 16 database for live checks.
13
+
14
+ ## Follow a change through the code
15
+
16
+ - **Models and queries.** `narabi.models.core` interprets model annotations and attaches persistence methods. `narabi.query.relation` compiles an immutable relation to SQL and bindings. The selected `Database` supplies the dialect and owns the connection. Relationship code in `narabi.relations` uses the same model metadata.
17
+ - **Schema changes.** `narabi.migrations.models` extracts the declaration, while replay reconstructs the schema from migration files. The diff and generator produce editable changes. The history and executor layers verify migration checksums, lock the target, detect drift, and apply changes within a migration transaction.
18
+ - **Entry points.** `narabi.cli` wires commands to project configuration and public APIs. Drivers and IPython load when their features are used. See the [architecture decisions](docs/architecture.md) for rationale.
19
+
20
+ Keep tests near the subsystem they exercise. When adding a teaching example, follow the existing `examples/features` layout for a focused capability or `examples/domain` for a workflow spanning several capabilities. Give the example a clean setup and a visible result.
21
+
22
+ ## Before opening a PR
23
+
24
+ Use the [Tests workflow](.github/workflows/tests.yml) as the source of truth for local parity. If packaging changes, build with `uv build --wheel` and install the wheel outside the checkout. Run CLI help and the feature smoke checks in clean core, SQLite, PostgreSQL, console, and all environments. Use the [Examples workflow](.github/workflows/examples.yml) to find the commands for domain and feature demos.
25
+
26
+ Make each commit describe one behavior change. In the PR, link the issue where applicable and state what you ran, including any backend checks that were unavailable.
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, RickBarretto
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice,
9
+ this list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its contributors
16
+ may be used to endorse or promote products derived from this software
17
+ without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,19 @@
1
+ # Why Narabi exists
2
+
3
+ I wanted a Python ORM I would reach for before writing SQL by hand.
4
+
5
+ With SQLAlchemy, I often found that writing the SQL directly felt easier than setting up the objects around it. I had the same experience with migration tools such as Alembic andkv Aerich. For the projects I was working on, the amount of code between the task and the result was more than I wanted to maintain. SQLModel's typed models appealed to me, but when I tried to use them asynchronously, the examples I needed were hard to find. These projects make different tradeoffs, and many applications benefit from them.
6
+
7
+ Rails Active Record gave me a model for what I wanted. Start with a book. Ask the book model for its rows. Save a change through the book you already have. Use a transaction when an operation needs one. Narabi brings that workflow to ordinary Python classes with type annotations and explicit `await`.
8
+
9
+ ## Make the common path short
10
+
11
+ A reader looking up a book should be able to follow the query without first learning how the application assembled its persistence layer. A developer reviewing a schema change should be able to read the generated migration, inspect the SQL, and see which changes require extra care. Narabi puts those operations in the same library so there is one workflow to learn.
12
+
13
+ Short code is valuable when each line does something you can name. Narabi uses conventions for choices such as table naming when a project opts in. It keeps transaction boundaries and schema changes visible. When SQL expresses an idea more directly, use `Database.execute()` with bound parameters.
14
+
15
+ ## Make sensitive fields visible in the model
16
+
17
+ The maintainer reading a customer model should be able to see which fields are personal, sensitive, or private. Narabi uses that classification to redact record representations, omit private fields from default serialization, and show an inventory of classified fields. The declaration sits beside the field it describes, where someone reviewing a change can see it.
18
+
19
+ Start with the [bookstore tutorial](docs/tutorial.md) or see [how the same workflow looks in other libraries](docs/comparisons.md).
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.5
2
+ Name: narabi-orm
3
+ Version: 0.1.0
4
+ Summary: An asynchronous Active Record ORM for Python.
5
+ Project-URL: Homepage, https://github.com/RickBarretto/narabi-orm
6
+ Project-URL: Documentation, https://github.com/RickBarretto/narabi-orm/tree/main/docs
7
+ Project-URL: Repository, https://github.com/RickBarretto/narabi-orm
8
+ Project-URL: Issues, https://github.com/RickBarretto/narabi-orm/issues
9
+ License-Expression: BSD-3-Clause
10
+ License-File: LICENSE
11
+ Keywords: active-record,async,orm,postgresql,sqlite
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Framework :: AsyncIO
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Database
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.12
19
+ Requires-Dist: attrs>=23.2
20
+ Requires-Dist: cattrs>=24.1
21
+ Requires-Dist: cyclopts<5,>=4
22
+ Provides-Extra: all
23
+ Requires-Dist: aiosqlite; extra == 'all'
24
+ Requires-Dist: ipython<10,>=9; extra == 'all'
25
+ Requires-Dist: psycopg-pool; extra == 'all'
26
+ Requires-Dist: psycopg[binary]; extra == 'all'
27
+ Provides-Extra: console
28
+ Requires-Dist: ipython<10,>=9; extra == 'console'
29
+ Provides-Extra: postgres
30
+ Requires-Dist: psycopg-pool; extra == 'postgres'
31
+ Requires-Dist: psycopg[binary]; extra == 'postgres'
32
+ Provides-Extra: sqlite
33
+ Requires-Dist: aiosqlite; extra == 'sqlite'
34
+ Provides-Extra: test
35
+ Requires-Dist: aiosqlite; extra == 'test'
36
+ Requires-Dist: ipython<10,>=9; extra == 'test'
37
+ Requires-Dist: pytest; extra == 'test'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # Narabi
41
+
42
+ Narabi is an async Active Record library for Python. Declare a model with ordinary type annotations, then create, query, and update rows through that model. Use SQLite for a local project or PostgreSQL for a service.
43
+
44
+ ```python
45
+ from narabi import Increment, Primary, table
46
+
47
+ @table
48
+ class Book:
49
+ id: Primary[int] = Increment()
50
+ title: str
51
+
52
+ book = await Book.create(title="A Wizard of Earthsea")
53
+ saved = await Book.require(book.id)
54
+ ```
55
+
56
+ The example assumes a project scaffolded with `narabi init` and a migrated `books` table. Narabi infers `books` from `Book`. The [bookstore tutorial](docs/tutorial.md) builds both from a clean directory.
57
+
58
+ ## Privacy belongs in the model
59
+
60
+ A bookstore needs a customer's contact details. Its logs and JSON responses rarely need all of them.
61
+
62
+ ```python
63
+ from narabi import Personal, Private, Sensitive, record
64
+
65
+ @record
66
+ class CustomerContact:
67
+ email: Personal[str]
68
+ access_token: Private[Sensitive[str]]
69
+
70
+ contact = CustomerContact(email="reader@example.test", access_token="demo-token")
71
+ print(contact)
72
+ # CustomerContact(email=<redacted>, access_token=<redacted>)
73
+ print(contact.to_dict())
74
+ # {'email': 'reader@example.test'}
75
+ ```
76
+
77
+ All three markers redact values in record representations. `Private` also omits the field from default serialization. `narabi privacy inventory` lists classifications from configured models without reading stored rows. If the record lives in a configured module named `models`, the inventory includes:
78
+
79
+ ```text
80
+ models.CustomerContact.email: Personal
81
+ models.CustomerContact.access_token: Private, Sensitive
82
+ ```
83
+
84
+ See [Privacy and serialization](docs/guides.md#privacy-and-serialization).
85
+
86
+ ## From a model to a running app
87
+
88
+ - Generate an editable Python migration, review the changes, and apply it. Render SQL offline or load a versioned schema snapshot. [Migration workflows](docs/guides.md#migrations-and-recovery)
89
+ - Compose queries, load associations, and inspect SQL and query plans. [API reference](docs/reference.md)
90
+ - Try a write in `narabi console --sandbox` and see it in the next cell. Exit to roll it back. [Console guide](docs/guides.md#console)
91
+ - Use the same models in a [FastAPI app](docs/fastapi.md) or a [Flask app](docs/flask.md).
92
+
93
+ ## How it fits
94
+
95
+ | Library | Where persistence lives |
96
+ | --- | --- |
97
+ | Narabi | Async operations on Python models, with a `Database` for connections and explicit transactions |
98
+ | Rails Active Record | Persistence and queries on Ruby models within the Rails conventions |
99
+ | SQLModel | Typed Python models based on Pydantic and SQLAlchemy, with persistence through a session |
100
+ | SQLAlchemy ORM | Mapped Python classes, SQL expressions, and a session that manages a unit of work |
101
+
102
+ [Compare the same bookstore operations](docs/comparisons.md) · [Why Narabi exists](PITCH.md) · [Documentation](docs/README.md) · [Contributing](CONTRIBUTING.md)
103
+
104
+ Narabi is released under the [BSD 3-Clause License](LICENSE).
@@ -0,0 +1,65 @@
1
+ # Narabi
2
+
3
+ Narabi is an async Active Record library for Python. Declare a model with ordinary type annotations, then create, query, and update rows through that model. Use SQLite for a local project or PostgreSQL for a service.
4
+
5
+ ```python
6
+ from narabi import Increment, Primary, table
7
+
8
+ @table
9
+ class Book:
10
+ id: Primary[int] = Increment()
11
+ title: str
12
+
13
+ book = await Book.create(title="A Wizard of Earthsea")
14
+ saved = await Book.require(book.id)
15
+ ```
16
+
17
+ The example assumes a project scaffolded with `narabi init` and a migrated `books` table. Narabi infers `books` from `Book`. The [bookstore tutorial](docs/tutorial.md) builds both from a clean directory.
18
+
19
+ ## Privacy belongs in the model
20
+
21
+ A bookstore needs a customer's contact details. Its logs and JSON responses rarely need all of them.
22
+
23
+ ```python
24
+ from narabi import Personal, Private, Sensitive, record
25
+
26
+ @record
27
+ class CustomerContact:
28
+ email: Personal[str]
29
+ access_token: Private[Sensitive[str]]
30
+
31
+ contact = CustomerContact(email="reader@example.test", access_token="demo-token")
32
+ print(contact)
33
+ # CustomerContact(email=<redacted>, access_token=<redacted>)
34
+ print(contact.to_dict())
35
+ # {'email': 'reader@example.test'}
36
+ ```
37
+
38
+ All three markers redact values in record representations. `Private` also omits the field from default serialization. `narabi privacy inventory` lists classifications from configured models without reading stored rows. If the record lives in a configured module named `models`, the inventory includes:
39
+
40
+ ```text
41
+ models.CustomerContact.email: Personal
42
+ models.CustomerContact.access_token: Private, Sensitive
43
+ ```
44
+
45
+ See [Privacy and serialization](docs/guides.md#privacy-and-serialization).
46
+
47
+ ## From a model to a running app
48
+
49
+ - Generate an editable Python migration, review the changes, and apply it. Render SQL offline or load a versioned schema snapshot. [Migration workflows](docs/guides.md#migrations-and-recovery)
50
+ - Compose queries, load associations, and inspect SQL and query plans. [API reference](docs/reference.md)
51
+ - Try a write in `narabi console --sandbox` and see it in the next cell. Exit to roll it back. [Console guide](docs/guides.md#console)
52
+ - Use the same models in a [FastAPI app](docs/fastapi.md) or a [Flask app](docs/flask.md).
53
+
54
+ ## How it fits
55
+
56
+ | Library | Where persistence lives |
57
+ | --- | --- |
58
+ | Narabi | Async operations on Python models, with a `Database` for connections and explicit transactions |
59
+ | Rails Active Record | Persistence and queries on Ruby models within the Rails conventions |
60
+ | SQLModel | Typed Python models based on Pydantic and SQLAlchemy, with persistence through a session |
61
+ | SQLAlchemy ORM | Mapped Python classes, SQL expressions, and a session that manages a unit of work |
62
+
63
+ [Compare the same bookstore operations](docs/comparisons.md) · [Why Narabi exists](PITCH.md) · [Documentation](docs/README.md) · [Contributing](CONTRIBUTING.md)
64
+
65
+ Narabi is released under the [BSD 3-Clause License](LICENSE).
@@ -0,0 +1,12 @@
1
+ # Narabi guides
2
+
3
+ [Back](../README.md) · [Summary](README.md) · [Next](tutorial.md)
4
+
5
+ - [Build a bookstore](tutorial.md) from a first row to relationships, transactions, and query inspection.
6
+ - [How-to guides](guides.md) cover configuration, pooling, migrations, privacy, testing, and the console.
7
+ - [Build a bookstore API with FastAPI](fastapi.md) or [Flask](flask.md).
8
+ - [Compare Narabi with Active Record, SQLModel, and SQLAlchemy](comparisons.md).
9
+ - [Architecture decisions](architecture.md) explain the tradeoffs behind the public APIs.
10
+ - [API reference](reference.md) lists the supported interfaces and their behavior.
11
+
12
+ [Back](../README.md) · [Summary](README.md) · [Next](tutorial.md)
@@ -0,0 +1,48 @@
1
+ # Architecture decisions
2
+
3
+ [Back](comparisons.md) · [Summary](README.md) · [Next](reference.md)
4
+
5
+ ## Models own persistence
6
+
7
+ Models declare fields with normal annotations. `@record` provides an in-memory
8
+ record, while `@table` adds persistence. `@value` groups attributes that have
9
+ meaning together and can be mapped to columns. This lets validation and
10
+ serialization work before a database is involved. A query becomes SQL when
11
+ it is executed, and a named relation can be composed before it is awaited.
12
+
13
+ ## A database owns connections and transactions
14
+
15
+ Models accept a `db=` argument, which keeps database selection visible when
16
+ an application has multiple targets. A standalone write has its own
17
+ transaction. An explicit transaction owns a connection in the current task,
18
+ and a nested transaction uses a savepoint. Independent tasks cannot
19
+ implicitly use that connection. PostgreSQL pooling changes how a connection
20
+ is acquired while the ownership rules stay the same.
21
+
22
+ ## Migration history and declarations answer different questions
23
+
24
+ A model says what the application expects today. Migration files say how to
25
+ reach a schema from an earlier version and can include operations such as
26
+ historical transformations or database-specific checks. Narabi compares
27
+ model declarations with replayed history to generate editable migrations.
28
+ Checksums and drift inspection help guard against applying a plan to the
29
+ wrong starting point. Snapshots use migration history so details outside the
30
+ models survive.
31
+
32
+ ## One configuration vocabulary, two homes
33
+
34
+ Use `narabi.toml` for a focused configuration or `[tool.narabi]` to keep
35
+ project tools together. SQLite, PostgreSQL, and IPython are install extras.
36
+ Models, queries, migrations, and privacy are part of the base package.
37
+
38
+ ## Privacy starts at declaration
39
+
40
+ Privacy markers live on the fields they describe. Representations redact
41
+ classified fields, and serialization excludes private fields by default.
42
+ Inventory is a static view of those decisions. For an API, an explicit
43
+ response schema still defines what crosses the boundary.
44
+
45
+ See [CONTRIBUTING.md](../CONTRIBUTING.md) for the implementation map and
46
+ [the comparison](comparisons.md) for how these choices differ across libraries.
47
+
48
+ [Back](comparisons.md) · [Summary](README.md) · [Next](reference.md)