sqlakit 0.3.0__tar.gz → 0.3.1__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 (26) hide show
  1. {sqlakit-0.3.0 → sqlakit-0.3.1}/PKG-INFO +37 -39
  2. {sqlakit-0.3.0 → sqlakit-0.3.1}/README.md +36 -38
  3. {sqlakit-0.3.0 → sqlakit-0.3.1}/pyproject.toml +3 -3
  4. {sqlakit-0.3.0 → sqlakit-0.3.1}/pyproject.toml.orig +3 -5
  5. {sqlakit-0.3.0 → sqlakit-0.3.1}/LICENSE +0 -0
  6. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/__init__.py +0 -0
  7. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/_base.py +0 -0
  8. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/_db.py +0 -0
  9. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/_discovery.py +0 -0
  10. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/_model.py +0 -0
  11. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/_query.py +0 -0
  12. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/_recording.py +0 -0
  13. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/_registry.py +0 -0
  14. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/_routing.py +0 -0
  15. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/_sql.py +0 -0
  16. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/asyncio/__init__.py +0 -0
  17. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/asyncio/_db.py +0 -0
  18. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/asyncio/_registry.py +0 -0
  19. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/asyncio/orm.py +0 -0
  20. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/asyncio/sql.py +0 -0
  21. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/exceptions.py +0 -0
  22. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/orm.py +0 -0
  23. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/py.typed +0 -0
  24. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/sql.py +0 -0
  25. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/testing.py +0 -0
  26. {sqlakit-0.3.0 → sqlakit-0.3.1}/sqlakit/types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlakit
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: A toolkit for SQLAlchemy applications.
5
5
  Keywords: sqlalchemy,database,orm,sql,asyncio
6
6
  Author: Anton Ruhlov
@@ -185,44 +185,6 @@ feed.next_cursor
185
185
  feed.previous_cursor
186
186
  ```
187
187
 
188
- ## Active Record
189
-
190
- An instance saves and deletes itself, and the query is available on the class:
191
-
192
- ```python
193
- from sqlalchemy.orm import Mapped, mapped_column
194
-
195
- from sqlakit import Database
196
- from sqlakit.orm import Model
197
-
198
- db = Database("postgresql+psycopg://localhost/app")
199
-
200
-
201
- class Note(Model):
202
- __tablename__ = "notes"
203
-
204
- id: Mapped[int] = mapped_column(primary_key=True)
205
- text: Mapped[str]
206
-
207
-
208
- Note.set_db(db)
209
-
210
- with db.transaction():
211
- note = Note(text="ada")
212
- note.save()
213
-
214
- Note.query.where(Note.text == "ada").all()
215
- note.delete()
216
- ```
217
-
218
- `set_db()` binds a model to a database. Call it on a base class and every model
219
- under it inherits the binding. With the global `db` from the section below you
220
- don't need it at all: the model uses the global registry automatically.
221
-
222
- This layer is optional. Everything else works on plain `SQLAlchemy` models, so
223
- if saving belongs in your repositories or services, skip `sqlakit.orm`
224
- entirely.
225
-
226
188
  ## Testing
227
189
 
228
190
  A test runs inside a transaction that rolls back at the end, so nothing the
@@ -328,6 +290,42 @@ with db.using("replica").connect():
328
290
  list_users() # the models read the replica
329
291
  ```
330
292
 
293
+ ## Active Record
294
+
295
+ An instance saves and deletes itself, and the query is available on the class.
296
+ A model on the registry needs no wiring of its own:
297
+
298
+ ```python
299
+ from sqlalchemy.orm import Mapped, mapped_column
300
+
301
+ from sqlakit import db
302
+ from sqlakit.orm import Model
303
+
304
+
305
+ class Note(Model):
306
+ __tablename__ = "notes"
307
+
308
+ id: Mapped[int] = mapped_column(primary_key=True)
309
+ text: Mapped[str]
310
+
311
+
312
+ with db.transaction():
313
+ note = Note(text="ada").save()
314
+
315
+ Note.query.where(Note.text == "ada").all()
316
+ note.delete()
317
+ ```
318
+
319
+ A model that belongs on another database in the registry names its alias with
320
+ `__db__ = "warehouse"`. With a `Database` of your own, `set_db()` binds the
321
+ model to it. Either goes on a base class, and every model under it inherits
322
+ the binding.
323
+
324
+ This layer is optional. Everything else works on plain `SQLAlchemy` models, so
325
+ if saving belongs in your repositories or services, skip `sqlakit.orm`
326
+ entirely. `SQLModel` classes are `SQLAlchemy` models, and work either way: the
327
+ [examples](examples/) show both.
328
+
331
329
  ## The async API
332
330
 
333
331
  The async API is identical: the same classes, the same methods. Only the import
@@ -153,44 +153,6 @@ feed.next_cursor
153
153
  feed.previous_cursor
154
154
  ```
155
155
 
156
- ## Active Record
157
-
158
- An instance saves and deletes itself, and the query is available on the class:
159
-
160
- ```python
161
- from sqlalchemy.orm import Mapped, mapped_column
162
-
163
- from sqlakit import Database
164
- from sqlakit.orm import Model
165
-
166
- db = Database("postgresql+psycopg://localhost/app")
167
-
168
-
169
- class Note(Model):
170
- __tablename__ = "notes"
171
-
172
- id: Mapped[int] = mapped_column(primary_key=True)
173
- text: Mapped[str]
174
-
175
-
176
- Note.set_db(db)
177
-
178
- with db.transaction():
179
- note = Note(text="ada")
180
- note.save()
181
-
182
- Note.query.where(Note.text == "ada").all()
183
- note.delete()
184
- ```
185
-
186
- `set_db()` binds a model to a database. Call it on a base class and every model
187
- under it inherits the binding. With the global `db` from the section below you
188
- don't need it at all: the model uses the global registry automatically.
189
-
190
- This layer is optional. Everything else works on plain `SQLAlchemy` models, so
191
- if saving belongs in your repositories or services, skip `sqlakit.orm`
192
- entirely.
193
-
194
156
  ## Testing
195
157
 
196
158
  A test runs inside a transaction that rolls back at the end, so nothing the
@@ -296,6 +258,42 @@ with db.using("replica").connect():
296
258
  list_users() # the models read the replica
297
259
  ```
298
260
 
261
+ ## Active Record
262
+
263
+ An instance saves and deletes itself, and the query is available on the class.
264
+ A model on the registry needs no wiring of its own:
265
+
266
+ ```python
267
+ from sqlalchemy.orm import Mapped, mapped_column
268
+
269
+ from sqlakit import db
270
+ from sqlakit.orm import Model
271
+
272
+
273
+ class Note(Model):
274
+ __tablename__ = "notes"
275
+
276
+ id: Mapped[int] = mapped_column(primary_key=True)
277
+ text: Mapped[str]
278
+
279
+
280
+ with db.transaction():
281
+ note = Note(text="ada").save()
282
+
283
+ Note.query.where(Note.text == "ada").all()
284
+ note.delete()
285
+ ```
286
+
287
+ A model that belongs on another database in the registry names its alias with
288
+ `__db__ = "warehouse"`. With a `Database` of your own, `set_db()` binds the
289
+ model to it. Either goes on a base class, and every model under it inherits
290
+ the binding.
291
+
292
+ This layer is optional. Everything else works on plain `SQLAlchemy` models, so
293
+ if saving belongs in your repositories or services, skip `sqlakit.orm`
294
+ entirely. `SQLModel` classes are `SQLAlchemy` models, and work either way: the
295
+ [examples](examples/) show both.
296
+
299
297
  ## The async API
300
298
 
301
299
  The async API is identical: the same classes, the same methods. Only the import
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sqlakit"
3
- version = "0.3.0"
3
+ version = "0.3.1"
4
4
  description = "A toolkit for SQLAlchemy applications."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -163,8 +163,8 @@ skip = "./.venv,./site,./uv.lock,./.git"
163
163
  [dependency-groups]
164
164
  dev = [
165
165
  "pytest>=9.1.1",
166
- "ty>=0.0.72",
167
- "ruff>=0.16.3",
166
+ "ty>=0.0.75",
167
+ "ruff>=0.16.5",
168
168
  "poethepoet>=0.48.0",
169
169
  "anyio>=4.14.2",
170
170
  "trio>=0.34.0",
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sqlakit"
3
- version = "0.3.0"
3
+ version = "0.3.1"
4
4
  description = "A toolkit for SQLAlchemy applications."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -30,8 +30,6 @@ Repository = "https://github.com/antonrh/sqlakit"
30
30
  Documentation = "https://github.com/antonrh/sqlakit"
31
31
 
32
32
  [project.optional-dependencies]
33
- # `greenlet`, which the async API runs on. `SQLAlchemy` installs it by itself
34
- # where a wheel exists, and this asks for it on the platforms where none does.
35
33
  asyncio = [
36
34
  "sqlalchemy[asyncio]>=2.0.22",
37
35
  ]
@@ -56,8 +54,8 @@ default-groups = ["dev", "docs"]
56
54
  [dependency-groups]
57
55
  dev = [
58
56
  "pytest>=9.1.1",
59
- "ty>=0.0.72",
60
- "ruff>=0.16.3",
57
+ "ty>=0.0.75",
58
+ "ruff>=0.16.5",
61
59
  "poethepoet>=0.48.0",
62
60
  "anyio>=4.14.2",
63
61
  "trio>=0.34.0",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes