vsql-python 1.2.5__tar.gz → 1.2.7__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.
- {vsql_python-1.2.5 → vsql_python-1.2.7}/PKG-INFO +30 -2
- {vsql_python-1.2.5 → vsql_python-1.2.7}/README.md +29 -1
- {vsql_python-1.2.5 → vsql_python-1.2.7}/src/vsql/__init__.py +8 -5
- {vsql_python-1.2.5 → vsql_python-1.2.7}/src/vsql/_connection.py +13 -3
- {vsql_python-1.2.5 → vsql_python-1.2.7}/src/vsql_python.egg-info/PKG-INFO +30 -2
- {vsql_python-1.2.5 → vsql_python-1.2.7}/src/vsql_python.egg-info/scm_version.json +2 -2
- {vsql_python-1.2.5 → vsql_python-1.2.7}/tests/test_vsql.py +8 -3
- {vsql_python-1.2.5 → vsql_python-1.2.7}/.github/workflows/release.yml +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/.github/workflows/test.yml +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/.gitignore +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/LICENSE +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/MANIFEST.in +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/example/main.py +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/internal/amalgamation/LICENSE +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/internal/amalgamation/LICENSE-V +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/internal/amalgamation/libvsql.c +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/internal/amalgamation/libvsql.h +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/libvsql_flags.json +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/pyproject.toml +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/scripts/update-amalgamation.sh +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/setup.cfg +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/setup.py +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/src/vsql/_convert.py +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/src/vsql/_errors.py +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/src/vsql/_libvsql.c +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/src/vsql_python.egg-info/SOURCES.txt +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/src/vsql_python.egg-info/dependency_links.txt +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/src/vsql_python.egg-info/scm_file_list.json +0 -0
- {vsql_python-1.2.5 → vsql_python-1.2.7}/src/vsql_python.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vsql-python
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.7
|
|
4
4
|
Summary: A DB-API 2.0 (PEP 249) driver for vsql, a single file or in-memory SQL database.
|
|
5
5
|
Author-email: Elliot Chance <elliotchance@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -61,7 +61,35 @@ the connection rolls it back). With `vsql.connect(..., autocommit=True)` (or
|
|
|
61
61
|
when all the rows of a query have been fetched. `START TRANSACTION`, `COMMIT`
|
|
62
62
|
and `ROLLBACK` can't be executed as statements.
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
With autocommit on, a query's transaction lasts until all of its rows have
|
|
65
|
+
been fetched (or its cursor is closed, or executes another statement), so a
|
|
66
|
+
cursor that's left part way through a query can block other connections that
|
|
67
|
+
write to the database file.
|
|
68
|
+
|
|
69
|
+
### Isolation levels
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
conn = vsql.connect("test.vsql", isolation_level="SERIALIZABLE", read_only=False)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`isolation_level` is `"READ COMMITTED"` (the default), `"SERIALIZABLE"`,
|
|
76
|
+
`"REPEATABLE READ"` (which vsql runs as `SERIALIZABLE`) or
|
|
77
|
+
`"READ UNCOMMITTED"` (which vsql runs as `READ COMMITTED`, and is always read
|
|
78
|
+
only), in any case. `read_only=True` starts `READ ONLY` transactions, where a
|
|
79
|
+
change is `25006`. They're for the transactions that the driver starts when
|
|
80
|
+
autocommit is off.
|
|
81
|
+
|
|
82
|
+
vsql's own default is `SERIALIZABLE`, but a `SERIALIZABLE` transaction waits
|
|
83
|
+
for the other transactions on the same file to finish (for up to 5 seconds,
|
|
84
|
+
then it's `40001`). With autocommit off, a connection is in a transaction from
|
|
85
|
+
its first statement until it commits or rolls back, so the driver's default is
|
|
86
|
+
`READ COMMITTED` instead, which only fails (`40001`) when two transactions
|
|
87
|
+
change the same row.
|
|
88
|
+
|
|
89
|
+
### Statements
|
|
90
|
+
|
|
91
|
+
Each `execute` is one statement (a `;` between statements is `42601`), and vsql
|
|
92
|
+
doesn't allow `--` comments (`42000`), but `/* ... */` comments work.
|
|
65
93
|
|
|
66
94
|
### Savepoints
|
|
67
95
|
|
|
@@ -42,7 +42,35 @@ the connection rolls it back). With `vsql.connect(..., autocommit=True)` (or
|
|
|
42
42
|
when all the rows of a query have been fetched. `START TRANSACTION`, `COMMIT`
|
|
43
43
|
and `ROLLBACK` can't be executed as statements.
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
With autocommit on, a query's transaction lasts until all of its rows have
|
|
46
|
+
been fetched (or its cursor is closed, or executes another statement), so a
|
|
47
|
+
cursor that's left part way through a query can block other connections that
|
|
48
|
+
write to the database file.
|
|
49
|
+
|
|
50
|
+
### Isolation levels
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
conn = vsql.connect("test.vsql", isolation_level="SERIALIZABLE", read_only=False)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`isolation_level` is `"READ COMMITTED"` (the default), `"SERIALIZABLE"`,
|
|
57
|
+
`"REPEATABLE READ"` (which vsql runs as `SERIALIZABLE`) or
|
|
58
|
+
`"READ UNCOMMITTED"` (which vsql runs as `READ COMMITTED`, and is always read
|
|
59
|
+
only), in any case. `read_only=True` starts `READ ONLY` transactions, where a
|
|
60
|
+
change is `25006`. They're for the transactions that the driver starts when
|
|
61
|
+
autocommit is off.
|
|
62
|
+
|
|
63
|
+
vsql's own default is `SERIALIZABLE`, but a `SERIALIZABLE` transaction waits
|
|
64
|
+
for the other transactions on the same file to finish (for up to 5 seconds,
|
|
65
|
+
then it's `40001`). With autocommit off, a connection is in a transaction from
|
|
66
|
+
its first statement until it commits or rolls back, so the driver's default is
|
|
67
|
+
`READ COMMITTED` instead, which only fails (`40001`) when two transactions
|
|
68
|
+
change the same row.
|
|
69
|
+
|
|
70
|
+
### Statements
|
|
71
|
+
|
|
72
|
+
Each `execute` is one statement (a `;` between statements is `42601`), and vsql
|
|
73
|
+
doesn't allow `--` comments (`42000`), but `/* ... */` comments work.
|
|
46
74
|
|
|
47
75
|
### Savepoints
|
|
48
76
|
|
|
@@ -19,7 +19,8 @@ Like PEP 249 requires, autocommit is off: the first statement starts a
|
|
|
19
19
|
transaction, which is ended by commit or rollback (or closing the connection,
|
|
20
20
|
which rolls it back). With autocommit on, each statement is committed when it
|
|
21
21
|
finishes, or when the rows of a query have all been fetched. START TRANSACTION,
|
|
22
|
-
COMMIT and ROLLBACK can't be executed as statements.
|
|
22
|
+
COMMIT and ROLLBACK can't be executed as statements. Each execute is one
|
|
23
|
+
statement, and vsql doesn't allow "--" comments.
|
|
23
24
|
|
|
24
25
|
A savepoint is made by executing SAVEPOINT, and released by executing RELEASE
|
|
25
26
|
SAVEPOINT. ROLLBACK TO SAVEPOINT can't be executed as a statement either, so
|
|
@@ -121,10 +122,12 @@ def connect(database, autocommit=False, isolation_level="READ COMMITTED", read_o
|
|
|
121
122
|
exist) or ":memory:".
|
|
122
123
|
|
|
123
124
|
isolation_level ("READ UNCOMMITTED", "READ COMMITTED", "REPEATABLE READ"
|
|
124
|
-
or "SERIALIZABLE") and read_only are for the transactions
|
|
125
|
-
when autocommit is off. vsql runs READ UNCOMMITTED as
|
|
126
|
-
REPEATABLE READ as SERIALIZABLE. A READ UNCOMMITTED
|
|
127
|
-
read only.
|
|
125
|
+
or "SERIALIZABLE", in any case) and read_only are for the transactions
|
|
126
|
+
that are started when autocommit is off. vsql runs READ UNCOMMITTED as
|
|
127
|
+
READ COMMITTED, and REPEATABLE READ as SERIALIZABLE. A READ UNCOMMITTED
|
|
128
|
+
transaction is always read only. The default is READ COMMITTED, rather
|
|
129
|
+
than vsql's SERIALIZABLE, since a SERIALIZABLE transaction waits for the
|
|
130
|
+
other transactions on the file to finish.
|
|
128
131
|
"""
|
|
129
132
|
|
|
130
133
|
return Connection(database, autocommit, isolation_level, read_only)
|
|
@@ -23,13 +23,14 @@ class Connection:
|
|
|
23
23
|
|
|
24
24
|
def __init__(self, database, autocommit=False, isolation_level="READ COMMITTED",
|
|
25
25
|
read_only=False):
|
|
26
|
+
level = isolation_level.upper() if isinstance(isolation_level, str) else None
|
|
26
27
|
try:
|
|
27
|
-
self._isolation_level = _isolation_levels[
|
|
28
|
+
self._isolation_level = _isolation_levels[level]
|
|
28
29
|
except KeyError:
|
|
29
30
|
raise ProgrammingError(f"unknown isolation level: {isolation_level!r}") from None
|
|
30
31
|
# A READ UNCOMMITTED transaction must be READ ONLY.
|
|
31
32
|
self._access_mode = (lib.SQL_TRANSACTION_READ_ONLY
|
|
32
|
-
if read_only or
|
|
33
|
+
if read_only or level == "READ UNCOMMITTED"
|
|
33
34
|
else lib.SQL_TRANSACTION_READ_WRITE)
|
|
34
35
|
self._autocommit = bool(autocommit)
|
|
35
36
|
self._in_transaction = False
|
|
@@ -171,6 +172,12 @@ class Connection:
|
|
|
171
172
|
|
|
172
173
|
return self.cursor().execute(operation, parameters)
|
|
173
174
|
|
|
175
|
+
def executemany(self, operation, seq_of_parameters):
|
|
176
|
+
"""Executes a statement for each sequence of parameters with a new
|
|
177
|
+
cursor, which is returned."""
|
|
178
|
+
|
|
179
|
+
return self.cursor().executemany(operation, seq_of_parameters)
|
|
180
|
+
|
|
174
181
|
def close(self):
|
|
175
182
|
"""Closes the connection and its cursors. A transaction that hasn't been
|
|
176
183
|
committed is rolled back. It does nothing if it's already closed."""
|
|
@@ -302,8 +309,9 @@ class Cursor:
|
|
|
302
309
|
|
|
303
310
|
def executemany(self, operation, seq_of_parameters):
|
|
304
311
|
"""Executes a statement for each sequence of parameters. rowcount is
|
|
305
|
-
the total of the rows affected."""
|
|
312
|
+
the total of the rows affected. It returns the cursor."""
|
|
306
313
|
|
|
314
|
+
self._check()
|
|
307
315
|
total = 0
|
|
308
316
|
for parameters in seq_of_parameters:
|
|
309
317
|
self.execute(operation, parameters)
|
|
@@ -312,6 +320,8 @@ class Cursor:
|
|
|
312
320
|
total += max(self.rowcount, 0)
|
|
313
321
|
self.rowcount = total
|
|
314
322
|
|
|
323
|
+
return self
|
|
324
|
+
|
|
315
325
|
def fetchone(self):
|
|
316
326
|
"""The next row as a tuple, or None if there are no more."""
|
|
317
327
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vsql-python
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.7
|
|
4
4
|
Summary: A DB-API 2.0 (PEP 249) driver for vsql, a single file or in-memory SQL database.
|
|
5
5
|
Author-email: Elliot Chance <elliotchance@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -61,7 +61,35 @@ the connection rolls it back). With `vsql.connect(..., autocommit=True)` (or
|
|
|
61
61
|
when all the rows of a query have been fetched. `START TRANSACTION`, `COMMIT`
|
|
62
62
|
and `ROLLBACK` can't be executed as statements.
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
With autocommit on, a query's transaction lasts until all of its rows have
|
|
65
|
+
been fetched (or its cursor is closed, or executes another statement), so a
|
|
66
|
+
cursor that's left part way through a query can block other connections that
|
|
67
|
+
write to the database file.
|
|
68
|
+
|
|
69
|
+
### Isolation levels
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
conn = vsql.connect("test.vsql", isolation_level="SERIALIZABLE", read_only=False)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`isolation_level` is `"READ COMMITTED"` (the default), `"SERIALIZABLE"`,
|
|
76
|
+
`"REPEATABLE READ"` (which vsql runs as `SERIALIZABLE`) or
|
|
77
|
+
`"READ UNCOMMITTED"` (which vsql runs as `READ COMMITTED`, and is always read
|
|
78
|
+
only), in any case. `read_only=True` starts `READ ONLY` transactions, where a
|
|
79
|
+
change is `25006`. They're for the transactions that the driver starts when
|
|
80
|
+
autocommit is off.
|
|
81
|
+
|
|
82
|
+
vsql's own default is `SERIALIZABLE`, but a `SERIALIZABLE` transaction waits
|
|
83
|
+
for the other transactions on the same file to finish (for up to 5 seconds,
|
|
84
|
+
then it's `40001`). With autocommit off, a connection is in a transaction from
|
|
85
|
+
its first statement until it commits or rolls back, so the driver's default is
|
|
86
|
+
`READ COMMITTED` instead, which only fails (`40001`) when two transactions
|
|
87
|
+
change the same row.
|
|
88
|
+
|
|
89
|
+
### Statements
|
|
90
|
+
|
|
91
|
+
Each `execute` is one statement (a `;` between statements is `42601`), and vsql
|
|
92
|
+
doesn't allow `--` comments (`42000`), but `/* ... */` comments work.
|
|
65
93
|
|
|
66
94
|
### Savepoints
|
|
67
95
|
|
|
@@ -424,8 +424,10 @@ def test_rowcount(conn):
|
|
|
424
424
|
assert cur.lastrowid is None
|
|
425
425
|
assert conn.execute("SELECT * FROM foo").rowcount == -1
|
|
426
426
|
|
|
427
|
-
cur.executemany("INSERT INTO foo (x) VALUES (?)", [[3], [4], [5]])
|
|
427
|
+
assert cur.executemany("INSERT INTO foo (x) VALUES (?)", [[3], [4], [5]]) is cur
|
|
428
428
|
assert cur.rowcount == 3
|
|
429
|
+
assert conn.executemany("INSERT INTO foo (x) VALUES (?)", [[6], [7]]).rowcount == 2
|
|
430
|
+
assert conn.executemany("INSERT INTO foo (x) VALUES (?)", []).rowcount == 0
|
|
429
431
|
|
|
430
432
|
|
|
431
433
|
def test_fetch(conn):
|
|
@@ -646,14 +648,15 @@ def test_commit_closes_cursors(path):
|
|
|
646
648
|
|
|
647
649
|
|
|
648
650
|
def test_isolation_levels(path):
|
|
649
|
-
for level in ["READ COMMITTED", "REPEATABLE READ", "SERIALIZABLE"]:
|
|
651
|
+
for level in ["READ COMMITTED", "REPEATABLE READ", "SERIALIZABLE", "serializable"]:
|
|
650
652
|
with vsql.connect(path, isolation_level=level) as conn:
|
|
651
653
|
assert scalar(conn, "VALUES 1") == 1
|
|
652
654
|
conn.execute("CREATE TABLE t (x INT)")
|
|
653
655
|
conn.rollback()
|
|
654
656
|
|
|
655
657
|
# READ UNCOMMITTED is always read only.
|
|
656
|
-
for options in [{"isolation_level": "READ UNCOMMITTED"},
|
|
658
|
+
for options in [{"isolation_level": "READ UNCOMMITTED"},
|
|
659
|
+
{"isolation_level": "read uncommitted"}, {"read_only": True}]:
|
|
657
660
|
with vsql.connect(path, **options) as conn:
|
|
658
661
|
assert scalar(conn, "VALUES 1") == 1
|
|
659
662
|
with pytest.raises(vsql.OperationalError) as e:
|
|
@@ -662,6 +665,8 @@ def test_isolation_levels(path):
|
|
|
662
665
|
|
|
663
666
|
with pytest.raises(vsql.ProgrammingError):
|
|
664
667
|
vsql.connect(path, isolation_level="SNAPSHOT")
|
|
668
|
+
with pytest.raises(vsql.ProgrammingError):
|
|
669
|
+
vsql.connect(path, isolation_level=None)
|
|
665
670
|
|
|
666
671
|
|
|
667
672
|
def test_persistence(path):
|
|
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
|
|
File without changes
|
|
File without changes
|