vsql-python 1.0.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 (75) hide show
  1. vsql_python-1.0.0/.github/workflows/release.yml +68 -0
  2. vsql_python-1.0.0/.github/workflows/test.yml +34 -0
  3. vsql_python-1.0.0/.gitignore +10 -0
  4. vsql_python-1.0.0/LICENSE +21 -0
  5. vsql_python-1.0.0/MANIFEST.in +3 -0
  6. vsql_python-1.0.0/PKG-INFO +156 -0
  7. vsql_python-1.0.0/README.md +137 -0
  8. vsql_python-1.0.0/example/main.py +35 -0
  9. vsql_python-1.0.0/internal/amalgamation/LICENSE +21 -0
  10. vsql_python-1.0.0/internal/amalgamation/LICENSE-V +21 -0
  11. vsql_python-1.0.0/internal/amalgamation/afunix.h +26 -0
  12. vsql_python-1.0.0/internal/amalgamation/atomic.h +571 -0
  13. vsql_python-1.0.0/internal/amalgamation/core_windows.c +25 -0
  14. vsql_python-1.0.0/internal/amalgamation/core_windows.h +9 -0
  15. vsql_python-1.0.0/internal/amalgamation/execute_capture_nix.c +7 -0
  16. vsql_python-1.0.0/internal/amalgamation/execute_capture_nix.h +266 -0
  17. vsql_python-1.0.0/internal/amalgamation/gc/cord.h +426 -0
  18. vsql_python-1.0.0/internal/amalgamation/gc/cord_pos.h +151 -0
  19. vsql_python-1.0.0/internal/amalgamation/gc/ec.h +91 -0
  20. vsql_python-1.0.0/internal/amalgamation/gc/gc.h +2826 -0
  21. vsql_python-1.0.0/internal/amalgamation/gc/gc_allocator.h +480 -0
  22. vsql_python-1.0.0/internal/amalgamation/gc/gc_backptr.h +109 -0
  23. vsql_python-1.0.0/internal/amalgamation/gc/gc_config_macros.h +548 -0
  24. vsql_python-1.0.0/internal/amalgamation/gc/gc_disclaim.h +85 -0
  25. vsql_python-1.0.0/internal/amalgamation/gc/gc_gcj.h +123 -0
  26. vsql_python-1.0.0/internal/amalgamation/gc/gc_inline.h +261 -0
  27. vsql_python-1.0.0/internal/amalgamation/gc/gc_mark.h +516 -0
  28. vsql_python-1.0.0/internal/amalgamation/gc/gc_pthread_redirects.h +140 -0
  29. vsql_python-1.0.0/internal/amalgamation/gc/gc_tiny_fl.h +107 -0
  30. vsql_python-1.0.0/internal/amalgamation/gc/gc_typed.h +196 -0
  31. vsql_python-1.0.0/internal/amalgamation/gc/gc_version.h +55 -0
  32. vsql_python-1.0.0/internal/amalgamation/gc/javaxfc.h +76 -0
  33. vsql_python-1.0.0/internal/amalgamation/gc/leak_detector.h +120 -0
  34. vsql_python-1.0.0/internal/amalgamation/gc.c +45932 -0
  35. vsql_python-1.0.0/internal/amalgamation/gc.h +4 -0
  36. vsql_python-1.0.0/internal/amalgamation/gc_boehm_helpers.c +64 -0
  37. vsql_python-1.0.0/internal/amalgamation/gc_debugger_linux.h +61 -0
  38. vsql_python-1.0.0/internal/amalgamation/getrandom_linux.h +33 -0
  39. vsql_python-1.0.0/internal/amalgamation/ipv6_v6only.h +5 -0
  40. vsql_python-1.0.0/internal/amalgamation/libvsql.c +27 -0
  41. vsql_python-1.0.0/internal/amalgamation/libvsql.h +1772 -0
  42. vsql_python-1.0.0/internal/amalgamation/libvsql_linux_amd64.c +106591 -0
  43. vsql_python-1.0.0/internal/amalgamation/libvsql_linux_arm64.c +106571 -0
  44. vsql_python-1.0.0/internal/amalgamation/libvsql_macos_amd64.c +106728 -0
  45. vsql_python-1.0.0/internal/amalgamation/libvsql_macos_arm64.c +106708 -0
  46. vsql_python-1.0.0/internal/amalgamation/libvsql_windows_amd64.c +108235 -0
  47. vsql_python-1.0.0/internal/amalgamation/segfault_handler_nix.c +56 -0
  48. vsql_python-1.0.0/internal/amalgamation/segfault_handler_nix.h +449 -0
  49. vsql_python-1.0.0/internal/amalgamation/segfault_handler_windows.h +52 -0
  50. vsql_python-1.0.0/internal/amalgamation/thread_helper.c +12 -0
  51. vsql_python-1.0.0/internal/amalgamation/thread_helper.h +96 -0
  52. vsql_python-1.0.0/internal/amalgamation/ticks_windows.c +3 -0
  53. vsql_python-1.0.0/internal/amalgamation/ticks_windows.h +31 -0
  54. vsql_python-1.0.0/internal/amalgamation/ticks_windows_api.h +6 -0
  55. vsql_python-1.0.0/internal/amalgamation/vsql_runtime.c +14 -0
  56. vsql_python-1.0.0/internal/amalgamation/vsql_runtime_linux.c +6 -0
  57. vsql_python-1.0.0/internal/amalgamation/vsql_runtime_macos.c +6 -0
  58. vsql_python-1.0.0/internal/amalgamation/vsql_runtime_windows.c +6 -0
  59. vsql_python-1.0.0/libvsql_flags.json +22 -0
  60. vsql_python-1.0.0/pyproject.toml +49 -0
  61. vsql_python-1.0.0/scripts/update-amalgamation.sh +92 -0
  62. vsql_python-1.0.0/setup.cfg +4 -0
  63. vsql_python-1.0.0/setup.py +85 -0
  64. vsql_python-1.0.0/src/vsql/__init__.py +181 -0
  65. vsql_python-1.0.0/src/vsql/_connection.py +358 -0
  66. vsql_python-1.0.0/src/vsql/_convert.py +184 -0
  67. vsql_python-1.0.0/src/vsql/_errors.py +102 -0
  68. vsql_python-1.0.0/src/vsql/_libvsql.c +610 -0
  69. vsql_python-1.0.0/src/vsql_python.egg-info/PKG-INFO +156 -0
  70. vsql_python-1.0.0/src/vsql_python.egg-info/SOURCES.txt +73 -0
  71. vsql_python-1.0.0/src/vsql_python.egg-info/dependency_links.txt +1 -0
  72. vsql_python-1.0.0/src/vsql_python.egg-info/scm_file_list.json +71 -0
  73. vsql_python-1.0.0/src/vsql_python.egg-info/scm_version.json +8 -0
  74. vsql_python-1.0.0/src/vsql_python.egg-info/top_level.txt +1 -0
  75. vsql_python-1.0.0/tests/test_vsql.py +456 -0
@@ -0,0 +1,68 @@
1
+ name: Release
2
+
3
+ # Wheels are built for each push to main (and pull request), and published to
4
+ # PyPI (with trusted publishing) when a GitHub release is published. The
5
+ # version is the release's tag (v1.2.3 is 1.2.3), from setuptools-scm, so the
6
+ # full git history is checked out.
7
+
8
+ on:
9
+ push:
10
+ branches: [main]
11
+ pull_request:
12
+ release:
13
+ types: [published]
14
+
15
+ jobs:
16
+ wheels:
17
+ name: Wheels for ${{ matrix.os }} (${{ matrix.arch }})
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ include:
22
+ - { os: Linux, arch: x86-64, runner: ubuntu-latest }
23
+ - { os: Linux, arch: ARM64, runner: ubuntu-24.04-arm }
24
+ - { os: macOS, arch: x86-64, runner: macos-15-intel }
25
+ - { os: macOS, arch: ARM64, runner: macos-latest }
26
+ - { os: Windows, arch: x86-64, runner: windows-latest }
27
+ runs-on: ${{ matrix.runner }}
28
+ steps:
29
+ - uses: actions/checkout@v7
30
+ with:
31
+ fetch-depth: 0
32
+ - uses: pypa/cibuildwheel@v4.3.1
33
+ - uses: actions/upload-artifact@v7
34
+ with:
35
+ name: wheels-${{ matrix.os }}-${{ matrix.arch }}
36
+ path: wheelhouse/*.whl
37
+
38
+ sdist:
39
+ name: Source distribution
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - uses: actions/checkout@v7
43
+ with:
44
+ fetch-depth: 0
45
+ - run: pipx run build --sdist
46
+ - uses: actions/upload-artifact@v7
47
+ with:
48
+ name: sdist
49
+ path: dist/*.tar.gz
50
+
51
+ publish:
52
+ name: Publish to PyPI
53
+ # Only a published GitHub release with a version tag (such as v1.0.0) is
54
+ # published to PyPI. Pushes and pull requests only build.
55
+ if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v')
56
+ needs: [wheels, sdist]
57
+ runs-on: ubuntu-latest
58
+ environment:
59
+ name: pypi
60
+ url: https://pypi.org/p/vsql-python
61
+ permissions:
62
+ id-token: write
63
+ steps:
64
+ - uses: actions/download-artifact@v8
65
+ with:
66
+ path: dist
67
+ merge-multiple: true
68
+ - uses: pypa/gh-action-pypi-publish@v1.14.2
@@ -0,0 +1,34 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ name: ${{ matrix.os }} (${{ matrix.arch }}), Python ${{ matrix.python }}
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ os: [Linux, macOS, Windows]
15
+ arch: [x86-64, ARM64]
16
+ python: ["3.9", "3.14"]
17
+ include:
18
+ - { os: Linux, arch: x86-64, runner: ubuntu-latest }
19
+ - { os: Linux, arch: ARM64, runner: ubuntu-24.04-arm }
20
+ - { os: macOS, arch: x86-64, runner: macos-15-intel }
21
+ - { os: macOS, arch: ARM64, runner: macos-latest }
22
+ - { os: Windows, arch: x86-64, runner: windows-latest }
23
+ exclude:
24
+ # There's no libvsql C for Windows ARM64.
25
+ - { os: Windows, arch: ARM64 }
26
+ runs-on: ${{ matrix.runner }}
27
+ steps:
28
+ - uses: actions/checkout@v7
29
+ - uses: actions/setup-python@v7
30
+ with:
31
+ python-version: ${{ matrix.python }}
32
+ - run: pip install . pytest
33
+ - run: pytest -v tests
34
+ - run: python example/main.py
@@ -0,0 +1,10 @@
1
+ *.vsql
2
+ *.vsql.*
3
+ __pycache__/
4
+ *.so
5
+ *.pyd
6
+ build/
7
+ dist/
8
+ *.egg-info/
9
+ .venv/
10
+ wheelhouse/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Elliot Chance
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ include libvsql_flags.json
2
+ recursive-include internal/amalgamation *
3
+ include src/vsql/*.c
@@ -0,0 +1,156 @@
1
+ Metadata-Version: 2.4
2
+ Name: vsql-python
3
+ Version: 1.0.0
4
+ Summary: A DB-API 2.0 (PEP 249) driver for vsql, a single file or in-memory SQL database.
5
+ Author-email: Elliot Chance <elliotchance@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/elliotchance/vsql-python
8
+ Project-URL: vsql, https://github.com/elliotchance/vsql
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: C
11
+ Classifier: Topic :: Database
12
+ Classifier: Topic :: Database :: Database Engines/Servers
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ License-File: internal/amalgamation/LICENSE
17
+ License-File: internal/amalgamation/LICENSE-V
18
+ Dynamic: license-file
19
+
20
+ # vsql-python
21
+
22
+ A [DB-API 2.0 (PEP 249)](https://peps.python.org/pep-0249/) driver for
23
+ [vsql](https://github.com/elliotchance/vsql), a single file or in-memory SQL
24
+ database. libvsql (the vsql library) is compiled into the package, so there's
25
+ nothing else to install.
26
+
27
+ ```sh
28
+ pip install vsql-python
29
+ ```
30
+
31
+ ```python
32
+ import vsql
33
+
34
+ with vsql.connect("test.vsql") as conn:
35
+ cur = conn.cursor()
36
+ cur.execute("CREATE TABLE foo (x INTEGER)")
37
+ cur.execute("INSERT INTO foo (x) VALUES (?)", [123])
38
+ conn.commit()
39
+
40
+ cur.execute("SELECT x FROM foo")
41
+ print(cur.fetchall()) # [(123,)]
42
+ ```
43
+
44
+ The database is the path of the file (it's created if it doesn't exist), or
45
+ `:memory:` for a database that only exists for the life of the connection.
46
+ Leaving the `with` block commits (or rolls back if there was an exception) and
47
+ closes the connection.
48
+
49
+ See [example/main.py](example/main.py) for a complete program:
50
+
51
+ ```sh
52
+ python example/main.py
53
+ ```
54
+
55
+ ## Transactions
56
+
57
+ As PEP 249 requires, autocommit is off: the first statement starts a
58
+ transaction, which is ended by `conn.commit()` or `conn.rollback()` (closing
59
+ the connection rolls it back). With `vsql.connect(..., autocommit=True)` (or
60
+ `conn.autocommit = True`), each statement is committed when it finishes, or
61
+ when all the rows of a query have been fetched. `START TRANSACTION`, `COMMIT`
62
+ and `ROLLBACK` can't be executed as statements.
63
+
64
+ vsql's transactions are `READ COMMITTED`.
65
+
66
+ ## Parameters
67
+
68
+ Parameters are `?` (`paramstyle` is `"qmark"`), given as a sequence. Each
69
+ Python type is sent as an SQL type, which is cast to the type it's used as:
70
+
71
+ | Python | SQL |
72
+ |---------------------------|----------------------------------------------|
73
+ | `None` | `NULL` |
74
+ | `bool` | `BOOLEAN` |
75
+ | `int` | `BIGINT` (`NUMERIC` if it's out of range) |
76
+ | `float` | `DOUBLE PRECISION` |
77
+ | `str` | `CHARACTER VARYING` |
78
+ | `decimal.Decimal` | `NUMERIC` (it must be finite) |
79
+ | `datetime.datetime` | `TIMESTAMP(6)` (`WITH TIME ZONE` if aware) |
80
+ | `datetime.date` | `DATE` |
81
+ | `datetime.time` | `TIME(6)` (`WITH TIME ZONE` if aware) |
82
+
83
+ vsql doesn't have a binary type, so `bytes` can't be a parameter.
84
+
85
+ ## Columns
86
+
87
+ | SQL | Python |
88
+ |----------------------------------|---------------------|
89
+ | `SMALLINT`, `INTEGER`, `BIGINT` | `int` |
90
+ | `REAL`, `DOUBLE PRECISION` | `float` |
91
+ | `DECIMAL`, `NUMERIC` | `decimal.Decimal` |
92
+ | `CHARACTER`, `VARCHAR` | `str` |
93
+ | `BOOLEAN` | `bool` |
94
+ | `DATE` | `datetime.date` |
95
+ | `TIME (WITH TIME ZONE)` | `datetime.time` |
96
+ | `TIMESTAMP (WITH TIME ZONE)` | `datetime.datetime` |
97
+
98
+ A `NULL` is `None`. A value `WITH TIME ZONE` is aware (with a fixed offset),
99
+ otherwise it's naive. The `type_code` in `cursor.description` is the name of
100
+ the type (such as `"INTEGER"`), which compares equal to `vsql.NUMBER`,
101
+ `vsql.STRING` or `vsql.DATETIME`.
102
+
103
+ ## Errors
104
+
105
+ An error from vsql is the PEP 249 exception for its SQLSTATE, with the
106
+ SQLSTATE as `sqlstate`:
107
+
108
+ ```python
109
+ try:
110
+ cur.execute("SELECT * FROM nope")
111
+ except vsql.ProgrammingError as e:
112
+ print(e.sqlstate) # 42P01
113
+ ```
114
+
115
+ | SQLSTATE class | Exception |
116
+ |------------------------------------------------|---------------------|
117
+ | `22` data exception | `DataError` |
118
+ | `23` integrity constraint violation | `IntegrityError` |
119
+ | `42` syntax error or access rule violation, `07`, `21`, `24`, `26`, `2B`, `34`, `3D`, `3F` | `ProgrammingError` |
120
+ | `0A` feature not supported, `HYC00` | `NotSupportedError` |
121
+ | `08`, `0B`, `25`, `2D`, `40`, `54`, `58`, `HY001` | `OperationalError` |
122
+ | `HY` CLI-specific condition | `InterfaceError` |
123
+ | `XX` internal error | `InternalError` |
124
+ | anything else | `DatabaseError` |
125
+
126
+ ## Threads
127
+
128
+ Each connection has its own libvsql environment, so different connections can
129
+ be used from different threads at the same time (`threadsafety` is 1: threads
130
+ can share the module, but not connections). The GIL is released while libvsql
131
+ runs.
132
+
133
+ ## Requirements
134
+
135
+ Python 3.9 or later. Wheels are built for macOS (ARM64 and x86-64), Linux
136
+ (ARM64 and x86-64) and Windows (x86-64), so pip doesn't need to compile
137
+ anything.
138
+
139
+ Building from the source distribution needs a C compiler, and takes about 30
140
+ seconds. On Windows, it needs clang-cl (from [LLVM](https://llvm.org), or the
141
+ "C++ Clang tools for Windows" component of Visual Studio) as well as MSVC, since
142
+ the C that V generates doesn't compile with MSVC. clang-cl is found on the
143
+ `PATH` (or in `C:\Program Files\LLVM\bin`), or set `CC` to its path.
144
+
145
+ ## Updating vsql
146
+
147
+ `internal/amalgamation` is the libvsql C from a vsql release
148
+ (`vsql-VERSION-amalgamation.zip`). To update it to the latest release:
149
+
150
+ ```sh
151
+ scripts/update-amalgamation.sh
152
+ pip install -e . && pytest
153
+ ```
154
+
155
+ Or give a version (`scripts/update-amalgamation.sh v1.2.3`), or a zip that has
156
+ already been downloaded.
@@ -0,0 +1,137 @@
1
+ # vsql-python
2
+
3
+ A [DB-API 2.0 (PEP 249)](https://peps.python.org/pep-0249/) driver for
4
+ [vsql](https://github.com/elliotchance/vsql), a single file or in-memory SQL
5
+ database. libvsql (the vsql library) is compiled into the package, so there's
6
+ nothing else to install.
7
+
8
+ ```sh
9
+ pip install vsql-python
10
+ ```
11
+
12
+ ```python
13
+ import vsql
14
+
15
+ with vsql.connect("test.vsql") as conn:
16
+ cur = conn.cursor()
17
+ cur.execute("CREATE TABLE foo (x INTEGER)")
18
+ cur.execute("INSERT INTO foo (x) VALUES (?)", [123])
19
+ conn.commit()
20
+
21
+ cur.execute("SELECT x FROM foo")
22
+ print(cur.fetchall()) # [(123,)]
23
+ ```
24
+
25
+ The database is the path of the file (it's created if it doesn't exist), or
26
+ `:memory:` for a database that only exists for the life of the connection.
27
+ Leaving the `with` block commits (or rolls back if there was an exception) and
28
+ closes the connection.
29
+
30
+ See [example/main.py](example/main.py) for a complete program:
31
+
32
+ ```sh
33
+ python example/main.py
34
+ ```
35
+
36
+ ## Transactions
37
+
38
+ As PEP 249 requires, autocommit is off: the first statement starts a
39
+ transaction, which is ended by `conn.commit()` or `conn.rollback()` (closing
40
+ the connection rolls it back). With `vsql.connect(..., autocommit=True)` (or
41
+ `conn.autocommit = True`), each statement is committed when it finishes, or
42
+ when all the rows of a query have been fetched. `START TRANSACTION`, `COMMIT`
43
+ and `ROLLBACK` can't be executed as statements.
44
+
45
+ vsql's transactions are `READ COMMITTED`.
46
+
47
+ ## Parameters
48
+
49
+ Parameters are `?` (`paramstyle` is `"qmark"`), given as a sequence. Each
50
+ Python type is sent as an SQL type, which is cast to the type it's used as:
51
+
52
+ | Python | SQL |
53
+ |---------------------------|----------------------------------------------|
54
+ | `None` | `NULL` |
55
+ | `bool` | `BOOLEAN` |
56
+ | `int` | `BIGINT` (`NUMERIC` if it's out of range) |
57
+ | `float` | `DOUBLE PRECISION` |
58
+ | `str` | `CHARACTER VARYING` |
59
+ | `decimal.Decimal` | `NUMERIC` (it must be finite) |
60
+ | `datetime.datetime` | `TIMESTAMP(6)` (`WITH TIME ZONE` if aware) |
61
+ | `datetime.date` | `DATE` |
62
+ | `datetime.time` | `TIME(6)` (`WITH TIME ZONE` if aware) |
63
+
64
+ vsql doesn't have a binary type, so `bytes` can't be a parameter.
65
+
66
+ ## Columns
67
+
68
+ | SQL | Python |
69
+ |----------------------------------|---------------------|
70
+ | `SMALLINT`, `INTEGER`, `BIGINT` | `int` |
71
+ | `REAL`, `DOUBLE PRECISION` | `float` |
72
+ | `DECIMAL`, `NUMERIC` | `decimal.Decimal` |
73
+ | `CHARACTER`, `VARCHAR` | `str` |
74
+ | `BOOLEAN` | `bool` |
75
+ | `DATE` | `datetime.date` |
76
+ | `TIME (WITH TIME ZONE)` | `datetime.time` |
77
+ | `TIMESTAMP (WITH TIME ZONE)` | `datetime.datetime` |
78
+
79
+ A `NULL` is `None`. A value `WITH TIME ZONE` is aware (with a fixed offset),
80
+ otherwise it's naive. The `type_code` in `cursor.description` is the name of
81
+ the type (such as `"INTEGER"`), which compares equal to `vsql.NUMBER`,
82
+ `vsql.STRING` or `vsql.DATETIME`.
83
+
84
+ ## Errors
85
+
86
+ An error from vsql is the PEP 249 exception for its SQLSTATE, with the
87
+ SQLSTATE as `sqlstate`:
88
+
89
+ ```python
90
+ try:
91
+ cur.execute("SELECT * FROM nope")
92
+ except vsql.ProgrammingError as e:
93
+ print(e.sqlstate) # 42P01
94
+ ```
95
+
96
+ | SQLSTATE class | Exception |
97
+ |------------------------------------------------|---------------------|
98
+ | `22` data exception | `DataError` |
99
+ | `23` integrity constraint violation | `IntegrityError` |
100
+ | `42` syntax error or access rule violation, `07`, `21`, `24`, `26`, `2B`, `34`, `3D`, `3F` | `ProgrammingError` |
101
+ | `0A` feature not supported, `HYC00` | `NotSupportedError` |
102
+ | `08`, `0B`, `25`, `2D`, `40`, `54`, `58`, `HY001` | `OperationalError` |
103
+ | `HY` CLI-specific condition | `InterfaceError` |
104
+ | `XX` internal error | `InternalError` |
105
+ | anything else | `DatabaseError` |
106
+
107
+ ## Threads
108
+
109
+ Each connection has its own libvsql environment, so different connections can
110
+ be used from different threads at the same time (`threadsafety` is 1: threads
111
+ can share the module, but not connections). The GIL is released while libvsql
112
+ runs.
113
+
114
+ ## Requirements
115
+
116
+ Python 3.9 or later. Wheels are built for macOS (ARM64 and x86-64), Linux
117
+ (ARM64 and x86-64) and Windows (x86-64), so pip doesn't need to compile
118
+ anything.
119
+
120
+ Building from the source distribution needs a C compiler, and takes about 30
121
+ seconds. On Windows, it needs clang-cl (from [LLVM](https://llvm.org), or the
122
+ "C++ Clang tools for Windows" component of Visual Studio) as well as MSVC, since
123
+ the C that V generates doesn't compile with MSVC. clang-cl is found on the
124
+ `PATH` (or in `C:\Program Files\LLVM\bin`), or set `CC` to its path.
125
+
126
+ ## Updating vsql
127
+
128
+ `internal/amalgamation` is the libvsql C from a vsql release
129
+ (`vsql-VERSION-amalgamation.zip`). To update it to the latest release:
130
+
131
+ ```sh
132
+ scripts/update-amalgamation.sh
133
+ pip install -e . && pytest
134
+ ```
135
+
136
+ Or give a version (`scripts/update-amalgamation.sh v1.2.3`), or a zip that has
137
+ already been downloaded.
@@ -0,0 +1,35 @@
1
+ # A complete program that uses vsql:
2
+ #
3
+ # python example/main.py
4
+
5
+ import datetime
6
+ import decimal
7
+
8
+ import vsql
9
+
10
+ with vsql.connect(":memory:") as conn:
11
+ cur = conn.cursor()
12
+ cur.execute("""CREATE TABLE products (
13
+ id INTEGER NOT NULL,
14
+ name VARCHAR(50) NOT NULL,
15
+ price NUMERIC(10, 2),
16
+ added DATE)""")
17
+ cur.executemany(
18
+ "INSERT INTO products (id, name, price, added) VALUES (?, ?, ?, ?)",
19
+ [
20
+ (1, "Bolt", decimal.Decimal("0.25"), datetime.date(2024, 1, 2)),
21
+ (2, "Nut", decimal.Decimal("0.10"), datetime.date(2024, 3, 4)),
22
+ (3, "Washer", None, None),
23
+ ],
24
+ )
25
+ conn.commit()
26
+
27
+ cur.execute("SELECT name, price, added FROM products WHERE id > ? ORDER BY id", [1])
28
+ print([d[0] for d in cur.description])
29
+ for name, price, added in cur:
30
+ print(name, price, added)
31
+
32
+ try:
33
+ cur.execute("SELECT * FROM nope")
34
+ except vsql.ProgrammingError as e:
35
+ print(f"{e.sqlstate}: {e.message}")
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Elliot Chance
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019-2024 Alexander Medvednikov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,26 @@
1
+ /**
2
+ * This file has no copyright assigned and is placed in the Public Domain.
3
+ * This file is part of the mingw-w64 runtime package.
4
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5
+ */
6
+
7
+ #ifndef _AFUNIX_
8
+ #define _AFUNIX_
9
+
10
+ #define UNIX_PATH_MAX 108
11
+
12
+ #if !defined(ADDRESS_FAMILY)
13
+ #define UNDEF_ADDRESS_FAMILY
14
+ #define ADDRESS_FAMILY unsigned short
15
+ #endif
16
+
17
+ typedef struct sockaddr_un {
18
+ ADDRESS_FAMILY sun_family;
19
+ char sun_path[UNIX_PATH_MAX];
20
+ } SOCKADDR_UN, *PSOCKADDR_UN;
21
+
22
+ #if defined(UNDEF_ADDRESS_FAMILY)
23
+ #undef ADDRESS_FAMILY
24
+ #endif
25
+
26
+ #endif /* _AFUNIX_ */