vsql-python 1.2.5__tar.gz → 1.2.8__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 (32) hide show
  1. {vsql_python-1.2.5 → vsql_python-1.2.8}/.github/workflows/test.yml +7 -0
  2. {vsql_python-1.2.5 → vsql_python-1.2.8}/PKG-INFO +36 -2
  3. {vsql_python-1.2.5 → vsql_python-1.2.8}/README.md +35 -1
  4. {vsql_python-1.2.5 → vsql_python-1.2.8}/pyproject.toml +3 -0
  5. {vsql_python-1.2.5 → vsql_python-1.2.8}/src/vsql/__init__.py +8 -5
  6. vsql_python-1.2.8/src/vsql/__init__.pyi +239 -0
  7. {vsql_python-1.2.5 → vsql_python-1.2.8}/src/vsql/_connection.py +13 -3
  8. vsql_python-1.2.8/src/vsql/_libvsql.pyi +6 -0
  9. vsql_python-1.2.8/src/vsql/py.typed +0 -0
  10. {vsql_python-1.2.5 → vsql_python-1.2.8}/src/vsql_python.egg-info/PKG-INFO +36 -2
  11. {vsql_python-1.2.5 → vsql_python-1.2.8}/src/vsql_python.egg-info/SOURCES.txt +3 -0
  12. {vsql_python-1.2.5 → vsql_python-1.2.8}/src/vsql_python.egg-info/scm_file_list.json +3 -0
  13. {vsql_python-1.2.5 → vsql_python-1.2.8}/src/vsql_python.egg-info/scm_version.json +2 -2
  14. {vsql_python-1.2.5 → vsql_python-1.2.8}/tests/test_vsql.py +8 -3
  15. {vsql_python-1.2.5 → vsql_python-1.2.8}/.github/workflows/release.yml +0 -0
  16. {vsql_python-1.2.5 → vsql_python-1.2.8}/.gitignore +0 -0
  17. {vsql_python-1.2.5 → vsql_python-1.2.8}/LICENSE +0 -0
  18. {vsql_python-1.2.5 → vsql_python-1.2.8}/MANIFEST.in +0 -0
  19. {vsql_python-1.2.5 → vsql_python-1.2.8}/example/main.py +0 -0
  20. {vsql_python-1.2.5 → vsql_python-1.2.8}/internal/amalgamation/LICENSE +0 -0
  21. {vsql_python-1.2.5 → vsql_python-1.2.8}/internal/amalgamation/LICENSE-V +0 -0
  22. {vsql_python-1.2.5 → vsql_python-1.2.8}/internal/amalgamation/libvsql.c +0 -0
  23. {vsql_python-1.2.5 → vsql_python-1.2.8}/internal/amalgamation/libvsql.h +0 -0
  24. {vsql_python-1.2.5 → vsql_python-1.2.8}/libvsql_flags.json +0 -0
  25. {vsql_python-1.2.5 → vsql_python-1.2.8}/scripts/update-amalgamation.sh +0 -0
  26. {vsql_python-1.2.5 → vsql_python-1.2.8}/setup.cfg +0 -0
  27. {vsql_python-1.2.5 → vsql_python-1.2.8}/setup.py +0 -0
  28. {vsql_python-1.2.5 → vsql_python-1.2.8}/src/vsql/_convert.py +0 -0
  29. {vsql_python-1.2.5 → vsql_python-1.2.8}/src/vsql/_errors.py +0 -0
  30. {vsql_python-1.2.5 → vsql_python-1.2.8}/src/vsql/_libvsql.c +0 -0
  31. {vsql_python-1.2.5 → vsql_python-1.2.8}/src/vsql_python.egg-info/dependency_links.txt +0 -0
  32. {vsql_python-1.2.5 → vsql_python-1.2.8}/src/vsql_python.egg-info/top_level.txt +0 -0
@@ -33,3 +33,10 @@ jobs:
33
33
  - run: pip install . pytest
34
34
  - run: pytest -v tests
35
35
  - run: python example/main.py
36
+ # The type hints (__init__.pyi) match the module, and the example passes
37
+ # mypy --strict with them.
38
+ - if: matrix.os == 'Linux' && matrix.arch == 'x86-64' && matrix.python == '3.14'
39
+ run: |
40
+ pip install mypy
41
+ python -m mypy.stubtest vsql --ignore-missing-stub
42
+ mypy --strict example/main.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vsql-python
3
- Version: 1.2.5
3
+ Version: 1.2.8
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
- vsql's transactions are `READ COMMITTED`.
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
 
@@ -228,6 +256,12 @@ be used from different threads at the same time (`threadsafety` is 1: threads
228
256
  can share the module, but not connections). The GIL is released while libvsql
229
257
  runs.
230
258
 
259
+ ## Type hints
260
+
261
+ The package has type hints (`vsql/__init__.pyi`), so type checkers such as
262
+ mypy and pyright know the types of the module, `Connection`, `Cursor`, the
263
+ parameters and the rows.
264
+
231
265
  ## Requirements
232
266
 
233
267
  Python 3.9 or later. Wheels are built for macOS (ARM64 and x86-64), Linux
@@ -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
- vsql's transactions are `READ COMMITTED`.
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
 
@@ -209,6 +237,12 @@ be used from different threads at the same time (`threadsafety` is 1: threads
209
237
  can share the module, but not connections). The GIL is released while libvsql
210
238
  runs.
211
239
 
240
+ ## Type hints
241
+
242
+ The package has type hints (`vsql/__init__.pyi`), so type checkers such as
243
+ mypy and pyright know the types of the module, `Connection`, `Cursor`, the
244
+ parameters and the rows.
245
+
212
246
  ## Requirements
213
247
 
214
248
  Python 3.9 or later. Wheels are built for macOS (ARM64 and x86-64), Linux
@@ -27,6 +27,9 @@ vsql = "https://github.com/elliotchance/vsql"
27
27
  package-dir = { "" = "src" }
28
28
  packages = ["vsql"]
29
29
 
30
+ [tool.setuptools.package-data]
31
+ vsql = ["py.typed", "*.pyi"]
32
+
30
33
  [tool.setuptools_scm]
31
34
  # For a build without the git history (such as a copy of the repository).
32
35
  fallback_version = "0.0.0"
@@ -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 that are started
125
- when autocommit is off. vsql runs READ UNCOMMITTED as READ COMMITTED, and
126
- REPEATABLE READ as SERIALIZABLE. A READ UNCOMMITTED transaction is always
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)
@@ -0,0 +1,239 @@
1
+ # Type hints for the vsql package (see __init__.py for the documentation).
2
+
3
+ import builtins
4
+ import datetime
5
+ import decimal
6
+ import os
7
+ from collections.abc import Iterable, Iterator, Sequence
8
+ from types import TracebackType
9
+ from typing import Any, Literal, Optional, Union
10
+
11
+ from typing_extensions import Self, TypeAlias
12
+
13
+ __all__ = [
14
+ "BINARY",
15
+ "DATETIME",
16
+ "NUMBER",
17
+ "ROWID",
18
+ "STRING",
19
+ "Binary",
20
+ "Connection",
21
+ "Cursor",
22
+ "DataError",
23
+ "DatabaseError",
24
+ "Date",
25
+ "DateFromTicks",
26
+ "Error",
27
+ "IntegrityError",
28
+ "InterfaceError",
29
+ "InternalError",
30
+ "NotSupportedError",
31
+ "OperationalError",
32
+ "ProgrammingError",
33
+ "Time",
34
+ "TimeFromTicks",
35
+ "Timestamp",
36
+ "TimestampFromTicks",
37
+ "Warning",
38
+ "YearMonthInterval",
39
+ "apilevel",
40
+ "build_info",
41
+ "connect",
42
+ "paramstyle",
43
+ "threadsafety",
44
+ "vsql_version",
45
+ "vsql_version_info",
46
+ ]
47
+
48
+ apilevel: str
49
+ threadsafety: int
50
+ paramstyle: str
51
+ vsql_version: str
52
+ vsql_version_info: tuple[int, ...]
53
+ build_info: dict[str, str]
54
+
55
+ # A value that can be a parameter.
56
+ _Parameter: TypeAlias = Union[
57
+ None,
58
+ bool,
59
+ int,
60
+ float,
61
+ str,
62
+ decimal.Decimal,
63
+ datetime.datetime,
64
+ datetime.date,
65
+ datetime.time,
66
+ bytes,
67
+ bytearray,
68
+ memoryview,
69
+ datetime.timedelta,
70
+ YearMonthInterval,
71
+ ]
72
+ # A value of a column.
73
+ _Value: TypeAlias = Union[
74
+ None,
75
+ bool,
76
+ int,
77
+ float,
78
+ str,
79
+ decimal.Decimal,
80
+ datetime.datetime,
81
+ datetime.date,
82
+ datetime.time,
83
+ bytes,
84
+ datetime.timedelta,
85
+ YearMonthInterval,
86
+ ]
87
+ _Row: TypeAlias = tuple[_Value, ...]
88
+ # (name, type_code, display_size, internal_size, precision, scale, null_ok)
89
+ _Column: TypeAlias = tuple[str, str, Optional[int], int, Optional[int], Optional[int], bool]
90
+ # None, but Any rather than Optional for an attribute that's usually checked
91
+ # by the code before (like typeshed's MaybeNone), such as the description of
92
+ # a query.
93
+ _MaybeNone: TypeAlias = Any
94
+ _IsolationLevel: TypeAlias = Literal[
95
+ "READ UNCOMMITTED", "READ COMMITTED", "REPEATABLE READ", "SERIALIZABLE"
96
+ ]
97
+
98
+ def connect(
99
+ database: Union[str, bytes, os.PathLike[str], os.PathLike[bytes]],
100
+ autocommit: bool = False,
101
+ isolation_level: _IsolationLevel = "READ COMMITTED",
102
+ read_only: bool = False,
103
+ ) -> Connection: ...
104
+
105
+ class Connection:
106
+ def __init__(
107
+ self,
108
+ database: Union[str, bytes, os.PathLike[str], os.PathLike[bytes]],
109
+ autocommit: bool = False,
110
+ isolation_level: _IsolationLevel = "READ COMMITTED",
111
+ read_only: bool = False,
112
+ ) -> None: ...
113
+ @property
114
+ def closed(self) -> bool: ...
115
+ @property
116
+ def autocommit(self) -> bool: ...
117
+ @autocommit.setter
118
+ def autocommit(self, value: bool) -> None: ...
119
+ @property
120
+ def in_transaction(self) -> bool: ...
121
+ @property
122
+ def file_version(self) -> tuple[int, int]: ...
123
+ def commit(self) -> None: ...
124
+ def rollback(self) -> None: ...
125
+ def rollback_to_savepoint(self, name: str) -> None: ...
126
+ def cursor(self) -> Cursor: ...
127
+ def execute(
128
+ self, operation: str, parameters: Optional[Sequence[_Parameter]] = None
129
+ ) -> Cursor: ...
130
+ def close(self) -> None: ...
131
+ def __del__(self) -> None: ...
132
+ def __enter__(self) -> Self: ...
133
+ def __exit__(
134
+ self,
135
+ exc_type: Optional[type[BaseException]],
136
+ exc_value: Optional[BaseException],
137
+ traceback: Optional[TracebackType],
138
+ ) -> None: ...
139
+
140
+ class Cursor:
141
+ connection: Connection
142
+ description: Union[tuple[_Column, ...], _MaybeNone]
143
+ rowcount: int
144
+ arraysize: int
145
+ lastrowid: None
146
+ def __init__(self, connection: Connection) -> None: ...
147
+ def execute(
148
+ self, operation: str, parameters: Optional[Sequence[_Parameter]] = None
149
+ ) -> Self: ...
150
+ def executemany(
151
+ self, operation: str, seq_of_parameters: Iterable[Sequence[_Parameter]]
152
+ ) -> None: ...
153
+ def fetchone(self) -> Optional[_Row]: ...
154
+ def fetchmany(self, size: Optional[int] = None) -> list[_Row]: ...
155
+ def fetchall(self) -> list[_Row]: ...
156
+ def __iter__(self) -> Iterator[_Row]: ...
157
+ def __next__(self) -> _Row: ...
158
+ def setinputsizes(self, sizes: Any) -> None: ...
159
+ def setoutputsize(self, size: Any, column: Optional[int] = None) -> None: ...
160
+ def close(self) -> None: ...
161
+ def __del__(self) -> None: ...
162
+ def __enter__(self) -> Self: ...
163
+ def __exit__(
164
+ self,
165
+ exc_type: Optional[type[BaseException]],
166
+ exc_value: Optional[BaseException],
167
+ traceback: Optional[TracebackType],
168
+ ) -> None: ...
169
+
170
+ class YearMonthInterval:
171
+ def __init__(self, years: int = 0, months: int = 0) -> None: ...
172
+ @property
173
+ def total_months(self) -> int: ...
174
+ @property
175
+ def years(self) -> int: ...
176
+ @property
177
+ def months(self) -> int: ...
178
+ def __eq__(self, other: object) -> bool: ...
179
+ def __hash__(self) -> int: ...
180
+ def __neg__(self) -> YearMonthInterval: ...
181
+
182
+ Date = datetime.date
183
+ Time = datetime.time
184
+ Timestamp = datetime.datetime
185
+ Binary = bytes
186
+
187
+ def DateFromTicks(ticks: float) -> datetime.date: ...
188
+ def TimeFromTicks(ticks: float) -> datetime.time: ...
189
+ def TimestampFromTicks(ticks: float) -> datetime.datetime: ...
190
+
191
+ class _TypeObject:
192
+ type_names: frozenset[str]
193
+ def __init__(self, *type_names: str) -> None: ...
194
+ def __eq__(self, other: object) -> bool: ...
195
+ def __ne__(self, other: object) -> bool: ...
196
+ def __hash__(self) -> int: ...
197
+
198
+ STRING: _TypeObject
199
+ BINARY: _TypeObject
200
+ NUMBER: _TypeObject
201
+ DATETIME: _TypeObject
202
+ ROWID: _TypeObject
203
+
204
+ class Warning(builtins.Exception): ...
205
+
206
+ class Error(builtins.Exception):
207
+ message: str
208
+ sqlstate: Optional[str]
209
+ constraint_catalog: Optional[str]
210
+ constraint_schema: Optional[str]
211
+ constraint_name: Optional[str]
212
+ catalog_name: Optional[str]
213
+ schema_name: Optional[str]
214
+ table_name: Optional[str]
215
+ column_name: Optional[str]
216
+ cursor_name: Optional[str]
217
+ def __init__(
218
+ self,
219
+ message: str,
220
+ sqlstate: Optional[str] = None,
221
+ *,
222
+ constraint_catalog: Optional[str] = None,
223
+ constraint_schema: Optional[str] = None,
224
+ constraint_name: Optional[str] = None,
225
+ catalog_name: Optional[str] = None,
226
+ schema_name: Optional[str] = None,
227
+ table_name: Optional[str] = None,
228
+ column_name: Optional[str] = None,
229
+ cursor_name: Optional[str] = None,
230
+ ) -> None: ...
231
+
232
+ class InterfaceError(Error): ...
233
+ class DatabaseError(Error): ...
234
+ class DataError(DatabaseError): ...
235
+ class OperationalError(DatabaseError): ...
236
+ class IntegrityError(DatabaseError): ...
237
+ class InternalError(DatabaseError): ...
238
+ class ProgrammingError(DatabaseError): ...
239
+ class NotSupportedError(DatabaseError): ...
@@ -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[isolation_level]
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 isolation_level == "READ UNCOMMITTED"
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
 
@@ -0,0 +1,6 @@
1
+ # The extension module (_libvsql.c) is private, so its functions and constants
2
+ # aren't typed.
3
+
4
+ from typing import Any
5
+
6
+ def __getattr__(name: str) -> Any: ...
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vsql-python
3
- Version: 1.2.5
3
+ Version: 1.2.8
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
- vsql's transactions are `READ COMMITTED`.
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
 
@@ -228,6 +256,12 @@ be used from different threads at the same time (`threadsafety` is 1: threads
228
256
  can share the module, but not connections). The GIL is released while libvsql
229
257
  runs.
230
258
 
259
+ ## Type hints
260
+
261
+ The package has type hints (`vsql/__init__.pyi`), so type checkers such as
262
+ mypy and pyright know the types of the module, `Connection`, `Cursor`, the
263
+ parameters and the rows.
264
+
231
265
  ## Requirements
232
266
 
233
267
  Python 3.9 or later. Wheels are built for macOS (ARM64 and x86-64), Linux
@@ -14,10 +14,13 @@ internal/amalgamation/libvsql.c
14
14
  internal/amalgamation/libvsql.h
15
15
  scripts/update-amalgamation.sh
16
16
  src/vsql/__init__.py
17
+ src/vsql/__init__.pyi
17
18
  src/vsql/_connection.py
18
19
  src/vsql/_convert.py
19
20
  src/vsql/_errors.py
20
21
  src/vsql/_libvsql.c
22
+ src/vsql/_libvsql.pyi
23
+ src/vsql/py.typed
21
24
  src/vsql_python.egg-info/PKG-INFO
22
25
  src/vsql_python.egg-info/SOURCES.txt
23
26
  src/vsql_python.egg-info/dependency_links.txt
@@ -16,10 +16,13 @@
16
16
  "scripts/update-amalgamation.sh",
17
17
  "setup.py",
18
18
  "src/vsql/__init__.py",
19
+ "src/vsql/__init__.pyi",
19
20
  "src/vsql/_connection.py",
20
21
  "src/vsql/_convert.py",
21
22
  "src/vsql/_errors.py",
22
23
  "src/vsql/_libvsql.c",
24
+ "src/vsql/_libvsql.pyi",
25
+ "src/vsql/py.typed",
23
26
  "tests/test_vsql.py"
24
27
  ]
25
28
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "tag": "1.2.5",
2
+ "tag": "1.2.8",
3
3
  "distance": 0,
4
- "node": "g5917873b5d9dffba5c0be595991adf4a0676e8d9",
4
+ "node": "gd09cbcb2c3550b92fc010f3885949334060233b0",
5
5
  "dirty": false,
6
6
  "branch": "HEAD",
7
7
  "node_date": "2026-11-27"
@@ -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"}, {"read_only": True}]:
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