sqlalchemy-boltons 1.0.0__py3-none-any.whl → 1.0.1__py3-none-any.whl
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.
- sqlalchemy_boltons-1.0.1.dist-info/METADATA +73 -0
- sqlalchemy_boltons-1.0.1.dist-info/RECORD +9 -0
- sqlalchemy_boltons-1.0.0.dist-info/METADATA +0 -57
- sqlalchemy_boltons-1.0.0.dist-info/RECORD +0 -9
- {sqlalchemy_boltons-1.0.0.dist-info → sqlalchemy_boltons-1.0.1.dist-info}/AUTHORS.md +0 -0
- {sqlalchemy_boltons-1.0.0.dist-info → sqlalchemy_boltons-1.0.1.dist-info}/LICENSE +0 -0
- {sqlalchemy_boltons-1.0.0.dist-info → sqlalchemy_boltons-1.0.1.dist-info}/WHEEL +0 -0
- {sqlalchemy_boltons-1.0.0.dist-info → sqlalchemy_boltons-1.0.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: sqlalchemy-boltons
|
3
|
+
Version: 1.0.1
|
4
|
+
Summary: Utilities that should've been inside SQLAlchemy but aren't
|
5
|
+
Author-email: Eduard Christian Dumitrescu <eduard.c.dumitrescu@gmail.com>
|
6
|
+
Maintainer-email: Eduard Christian Dumitrescu <eduard.c.dumitrescu@gmail.com>
|
7
|
+
License: MIT
|
8
|
+
Project-URL: Homepage, https://hydra.ecd.space/deaduard/sqlalchemy_boltons/
|
9
|
+
Project-URL: Changelog, https://hydra.ecd.space/deaduard/sqlalchemy_boltons/file?name=CHANGELOG.md&ci=trunk
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
11
|
+
Description-Content-Type: text/markdown
|
12
|
+
License-File: LICENSE
|
13
|
+
License-File: AUTHORS.md
|
14
|
+
|
15
|
+
# sqlalchemy_boltons
|
16
|
+
|
17
|
+
SQLAlchemy is great. However, it doesn't have everything built-in. Some important things are missing, and need to be
|
18
|
+
"bolted on".
|
19
|
+
|
20
|
+
(Name inspired from [boltons](https://pypi.org/project/boltons/). Not affiliated.)
|
21
|
+
|
22
|
+
## sqlite
|
23
|
+
|
24
|
+
SQLAlchemy doesn't automatically fix pysqlite's broken transaction handling. This module implements the
|
25
|
+
[usual fix](https://docs.sqlalchemy.org/en/20/dialects/sqlite.html#serializable-isolation-savepoints-transactional-ddl)
|
26
|
+
for that well-known broken behaviour, and also adds extra features on top of that.
|
27
|
+
|
28
|
+
You can [customize](https://docs.sqlalchemy.org/en/20/core/connections.html#sqlalchemy.engine.Engine.execution_options),
|
29
|
+
on a per-engine or per-connection basis:
|
30
|
+
|
31
|
+
- `x_sqlite_begin_mode`: The type of transaction to be started, such as "BEGIN" or
|
32
|
+
"[BEGIN IMMEDIATE](https://www.sqlite.org/lang_transaction.html)" (or
|
33
|
+
"[BEGIN CONCURRENT](https://www.sqlite.org/cgi/src/doc/begin-concurrent/doc/begin_concurrent.md)" someday maybe).
|
34
|
+
- `x_sqlite_foreign_keys`: The [foreign-key enforcement setting](https://www.sqlite.org/foreignkeys.html). Can be
|
35
|
+
`True`, `False`, or `"defer"`.
|
36
|
+
- `x_sqlite_journal_mode`: The [journal mode](https://www.sqlite.org/pragma.html#pragma_journal_mode) such as
|
37
|
+
`"DELETE"` or `"WAL"`.
|
38
|
+
|
39
|
+
Here's a minimal example:
|
40
|
+
|
41
|
+
```python
|
42
|
+
from sqlalchemy.orm import sessionmaker
|
43
|
+
from sqlalchemy_boltons.sqlite import create_engine_sqlite
|
44
|
+
|
45
|
+
engine = create_engine_sqlite(
|
46
|
+
"file.db",
|
47
|
+
journal_mode="WAL",
|
48
|
+
timeout=0.5,
|
49
|
+
create_engine_args={"echo": True},
|
50
|
+
)
|
51
|
+
|
52
|
+
# Configure the engine to use a plain "BEGIN" to start transactions and
|
53
|
+
# and to use deferred enforcement of foreign keys (recommended!)
|
54
|
+
engine = engine.execution_options(
|
55
|
+
x_sqlite_begin_mode=None, x_sqlite_foreign_keys="defer"
|
56
|
+
)
|
57
|
+
|
58
|
+
# Make a separate engine for write transactions using "BEGIN IMMEDIATE"
|
59
|
+
# for eager locking.
|
60
|
+
engine_w = engine.execution_options(x_sqlite_begin_mode="IMMEDIATE")
|
61
|
+
|
62
|
+
# Construct a sessionmaker for each engine.
|
63
|
+
Session = sessionmaker(engine)
|
64
|
+
SessionW = sessionmaker(engine_w)
|
65
|
+
|
66
|
+
# read-only transaction
|
67
|
+
with Session() as session:
|
68
|
+
session.execute(select(...))
|
69
|
+
|
70
|
+
# lock the database eagerly for writing
|
71
|
+
with SessionW() as session:
|
72
|
+
session.execute(update(...))
|
73
|
+
```
|
@@ -0,0 +1,9 @@
|
|
1
|
+
sqlalchemy_boltons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
sqlalchemy_boltons/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
sqlalchemy_boltons/sqlite.py,sha256=fIS9rsmEFRakSl8DLwHqVJ-M9K1w6Q0XEJieYNH1b98,7985
|
4
|
+
sqlalchemy_boltons-1.0.1.dist-info/AUTHORS.md,sha256=sXkm88GaYJ63k0Hy7UlGboAT4aytU8e1_K0wNo7WwD8,144
|
5
|
+
sqlalchemy_boltons-1.0.1.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
sqlalchemy_boltons-1.0.1.dist-info/METADATA,sha256=t5yyOnZzl415Jo4q4gh2YeJD-EtDYdLEdqT0qolPzn4,2852
|
7
|
+
sqlalchemy_boltons-1.0.1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
8
|
+
sqlalchemy_boltons-1.0.1.dist-info/top_level.txt,sha256=mlvZ3R5FelrQt2SNXCtw2bDXcTROxl5O_gDFnWXPQ84,19
|
9
|
+
sqlalchemy_boltons-1.0.1.dist-info/RECORD,,
|
@@ -1,57 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: sqlalchemy-boltons
|
3
|
-
Version: 1.0.0
|
4
|
-
Summary: Utilities that should've been inside SQLAlchemy but aren't
|
5
|
-
Author-email: Eduard Christian Dumitrescu <eduard.c.dumitrescu@gmail.com>
|
6
|
-
Maintainer-email: Eduard Christian Dumitrescu <eduard.c.dumitrescu@gmail.com>
|
7
|
-
License: MIT
|
8
|
-
Project-URL: Homepage, https://hydra.ecd.space/deaduard/sqlalchemy_boltons/
|
9
|
-
Project-URL: Changelog, https://hydra.ecd.space/deaduard/sqlalchemy_boltons/file?name=CHANGELOG.md&ci=trunk
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
11
|
-
Description-Content-Type: text/markdown
|
12
|
-
License-File: LICENSE
|
13
|
-
License-File: AUTHORS.md
|
14
|
-
|
15
|
-
# sqlalchemy_boltons
|
16
|
-
|
17
|
-
SQLAlchemy is great. However, it doesn't have everything built-in. Some important things are missing, and need to be
|
18
|
-
"bolted on".
|
19
|
-
|
20
|
-
(Name inspired from [boltons](https://pypi.org/project/boltons/). Not affiliated.)
|
21
|
-
|
22
|
-
## sqlite
|
23
|
-
|
24
|
-
SQLAlchemy doesn't automatically fix pysqlite's broken transaction handling. Instead, it provides a recipe for doing so
|
25
|
-
inside the [documentation](https://docs.sqlalchemy.org/en/20/dialects/sqlite.html#serializable-isolation-savepoints-transactional-ddl).
|
26
|
-
This module implements a fix for that broken behaviour.
|
27
|
-
|
28
|
-
You can customize, on a per-engine or per-connection basis:
|
29
|
-
|
30
|
-
- The type of transaction to be started, such as BEGIN or
|
31
|
-
[BEGIN IMMEDIATE](https://www.sqlite.org/lang_transaction.html) (or
|
32
|
-
[BEGIN CONCURRENT](https://www.sqlite.org/cgi/src/doc/begin-concurrent/doc/begin_concurrent.md) someday maybe).
|
33
|
-
- The [foreign-key enforcement setting](https://www.sqlite.org/foreignkeys.html). Can be `True`, `False`, or `"defer"`.
|
34
|
-
- The [journal mode](https://www.sqlite.org/pragma.html#pragma_journal_mode) such as DELETE or WAL.
|
35
|
-
|
36
|
-
```python
|
37
|
-
from sqlalchemy.orm import sessionmaker
|
38
|
-
from sqlalchemy_boltons.sqlite import create_engine_sqlite
|
39
|
-
|
40
|
-
engine = create_engine_sqlite("file.db", journal_mode="WAL", timeout=0.5, create_engine_args={"echo": True})
|
41
|
-
|
42
|
-
# use standard "BEGIN" and use deferred enforcement of foreign keys
|
43
|
-
engine = engine.execution_options(x_sqlite_begin_mode=None, x_sqlite_foreign_keys="defer")
|
44
|
-
|
45
|
-
# make a separate engine for write transactions using "BEGIN IMMEDIATE" for eager locking
|
46
|
-
engine_w = engine.execution_options(x_sqlite_begin_mode="IMMEDIATE")
|
47
|
-
|
48
|
-
Session = sessionmaker(engine)
|
49
|
-
SessionW = sessionmaker(engine_w)
|
50
|
-
|
51
|
-
with Session() as session:
|
52
|
-
session.execute(select(...))
|
53
|
-
|
54
|
-
# this locks the database eagerly
|
55
|
-
with SessionW() as session:
|
56
|
-
session.execute(update(...))
|
57
|
-
```
|
@@ -1,9 +0,0 @@
|
|
1
|
-
sqlalchemy_boltons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
sqlalchemy_boltons/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
sqlalchemy_boltons/sqlite.py,sha256=fIS9rsmEFRakSl8DLwHqVJ-M9K1w6Q0XEJieYNH1b98,7985
|
4
|
-
sqlalchemy_boltons-1.0.0.dist-info/AUTHORS.md,sha256=sXkm88GaYJ63k0Hy7UlGboAT4aytU8e1_K0wNo7WwD8,144
|
5
|
-
sqlalchemy_boltons-1.0.0.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
sqlalchemy_boltons-1.0.0.dist-info/METADATA,sha256=fb70ARFvxpuPDdnyJBJ9Rrjiw6aidC-VEM6qXeTh2hs,2466
|
7
|
-
sqlalchemy_boltons-1.0.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
8
|
-
sqlalchemy_boltons-1.0.0.dist-info/top_level.txt,sha256=mlvZ3R5FelrQt2SNXCtw2bDXcTROxl5O_gDFnWXPQ84,19
|
9
|
-
sqlalchemy_boltons-1.0.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|