pyturso 0.4.0rc9__cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.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.
Potentially problematic release.
This version of pyturso might be problematic. Click here for more details.
- pyturso-0.4.0rc9.dist-info/METADATA +209 -0
- pyturso-0.4.0rc9.dist-info/RECORD +14 -0
- pyturso-0.4.0rc9.dist-info/WHEEL +5 -0
- turso/__init__.py +41 -0
- turso/_turso.cpython-313-x86_64-linux-gnu.so +0 -0
- turso/aio/__init__.py +7 -0
- turso/aio/sync/__init__.py +15 -0
- turso/lib.py +926 -0
- turso/lib_aio.py +351 -0
- turso/lib_sync.py +468 -0
- turso/lib_sync_aio.py +93 -0
- turso/py.typed +0 -0
- turso/sync/__init__.py +15 -0
- turso/worker.py +43 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyturso
|
|
3
|
+
Version: 0.4.0rc9
|
|
4
|
+
Classifier: Development Status :: 3 - Alpha
|
|
5
|
+
Classifier: Programming Language :: Python
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Rust
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
+
Classifier: Operating System :: MacOS
|
|
18
|
+
Classifier: Topic :: Database
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Topic :: Database :: Database Engines/Servers
|
|
22
|
+
Requires-Dist: typing-extensions>=4.6.0,!=4.7.0
|
|
23
|
+
Requires-Dist: mypy==1.11.0 ; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest==8.3.1 ; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest-cov==5.0.0 ; extra == 'dev'
|
|
26
|
+
Requires-Dist: ruff==0.5.4 ; extra == 'dev'
|
|
27
|
+
Requires-Dist: coverage==7.6.1 ; extra == 'dev'
|
|
28
|
+
Requires-Dist: maturin==1.7.8 ; extra == 'dev'
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Summary: Turso is a work-in-progress, in-process OLTP database management system, compatible with SQLite.
|
|
31
|
+
Requires-Python: >=3.9
|
|
32
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
33
|
+
Project-URL: Homepage, https://github.com/tursodatabase/turso
|
|
34
|
+
Project-URL: Source, https://github.com/tursodatabase/turso
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<h1 align="center">Turso Database for Python</h1>
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
<p align="center">
|
|
41
|
+
<a title="Python" target="_blank" href="https://pypi.org/project/pyturso/"><img alt="PyPI" src="https://img.shields.io/pypi/v/pyturso"></a>
|
|
42
|
+
<a title="MIT" target="_blank" href="https://github.com/tursodatabase/turso/blob/main/LICENSE.md"><img src="http://img.shields.io/badge/license-MIT-orange.svg?style=flat-square"></a>
|
|
43
|
+
</p>
|
|
44
|
+
<p align="center">
|
|
45
|
+
<a title="Users Discord" target="_blank" href="https://tur.so/discord"><img alt="Chat with other users of Turso on Discord" src="https://img.shields.io/discord/933071162680958986?label=Discord&logo=Discord&style=social"></a>
|
|
46
|
+
</p>
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## About
|
|
51
|
+
|
|
52
|
+
> **⚠️ Warning:** This software is in BETA. It may still contain bugs and unexpected behavior. Use caution with production data and ensure you have backups.
|
|
53
|
+
|
|
54
|
+
## Features
|
|
55
|
+
|
|
56
|
+
- **SQLite compatible:** SQLite query language and file format support ([status](https://github.com/tursodatabase/turso/blob/main/COMPAT.md)).
|
|
57
|
+
- **In-process**: No network overhead, runs directly in your Python process
|
|
58
|
+
- **Cross-platform**: Supports Linux, macOS, Windows
|
|
59
|
+
- **Remote partial sync**: Bootstrap from a remote database, pull remote changes, and push local changes when online — all while enjoying a fully operational database offline.
|
|
60
|
+
- **Asyncio support**: Built-in integration with asyncio to ensure queries won’t block your event loop
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
uv pip install pyturso
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Database driver
|
|
69
|
+
|
|
70
|
+
A minimal DB‑API 2.0 example using an in‑memory database:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import turso
|
|
74
|
+
|
|
75
|
+
# Standard DB-API usage
|
|
76
|
+
conn = turso.connect(":memory:")
|
|
77
|
+
cur = conn.cursor()
|
|
78
|
+
|
|
79
|
+
cur.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT)")
|
|
80
|
+
cur.execute("INSERT INTO users VALUES (1, 'alice'), (2, 'bob')")
|
|
81
|
+
|
|
82
|
+
cur.execute("SELECT * FROM users ORDER BY id")
|
|
83
|
+
rows = cur.fetchall()
|
|
84
|
+
print(rows) # [(1, 'alice'), (2, 'bob')]
|
|
85
|
+
|
|
86
|
+
conn.close()
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Database driver (asyncio)
|
|
90
|
+
|
|
91
|
+
Non-blocking access with asyncio:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
import asyncio
|
|
95
|
+
import turso.aio
|
|
96
|
+
|
|
97
|
+
async def main():
|
|
98
|
+
# Connect and use as an async context manager
|
|
99
|
+
async with turso.aio.connect(":memory:") as conn:
|
|
100
|
+
# Executes multiple statements
|
|
101
|
+
await conn.executescript("""
|
|
102
|
+
CREATE TABLE t (id INTEGER PRIMARY KEY, name TEXT);
|
|
103
|
+
INSERT INTO t(name) VALUES ('alice'), ('bob');
|
|
104
|
+
""")
|
|
105
|
+
|
|
106
|
+
# Use a cursor for parameterized queries
|
|
107
|
+
cur = conn.cursor()
|
|
108
|
+
await cur.execute("SELECT COUNT(*) FROM t WHERE name LIKE ?", ("a%",))
|
|
109
|
+
count = (await cur.fetchone())[0]
|
|
110
|
+
print(count) # 1
|
|
111
|
+
|
|
112
|
+
# JSON and generate_series also available
|
|
113
|
+
cur = conn.cursor()
|
|
114
|
+
await cur.execute("SELECT SUM(value) FROM generate_series(1, 10)")
|
|
115
|
+
print((await cur.fetchone())[0]) # 55
|
|
116
|
+
|
|
117
|
+
asyncio.run(main())
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Synchronization driver
|
|
121
|
+
|
|
122
|
+
Use a remote Turso database while working locally. You can bootstrap local state from the remote, pull remote changes, and push local commits.
|
|
123
|
+
|
|
124
|
+
Note: You need a Turso remote URL. See the Turso docs for provisioning and authentication.
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
import turso.sync
|
|
128
|
+
|
|
129
|
+
# Connect a local database to a remote Turso database
|
|
130
|
+
conn = turso.sync.connect(
|
|
131
|
+
":memory:", # local db path (or a file path)
|
|
132
|
+
remote_url="https://<db>.<region>.turso.io" # your remote URL
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Read data (fetched from remote if not present locally yet)
|
|
136
|
+
rows = conn.execute("SELECT * FROM t").fetchall()
|
|
137
|
+
print(rows)
|
|
138
|
+
|
|
139
|
+
# Pull new changes from remote into local
|
|
140
|
+
changed = conn.pull()
|
|
141
|
+
print("Pulled:", changed) # True if there were new remote changes
|
|
142
|
+
|
|
143
|
+
# Make local changes
|
|
144
|
+
conn.execute("INSERT INTO t VALUES ('push works')")
|
|
145
|
+
conn.commit()
|
|
146
|
+
|
|
147
|
+
# Push local commits to remote
|
|
148
|
+
conn.push()
|
|
149
|
+
|
|
150
|
+
# Optional: inspect and manage sync state
|
|
151
|
+
stats = conn.stats()
|
|
152
|
+
print("Network received (bytes):", stats.network_received_bytes)
|
|
153
|
+
conn.checkpoint() # compact local WAL after many writes
|
|
154
|
+
|
|
155
|
+
conn.close()
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Partial bootstrap to reduce initial network cost:
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
import turso.sync
|
|
162
|
+
|
|
163
|
+
conn = turso.sync.connect(
|
|
164
|
+
"local.db",
|
|
165
|
+
remote_url="https://<db>.<region>.turso.io",
|
|
166
|
+
partial_boostrap_strategy=turso.sync.PartialSyncPrefixBootstrap(128 * 1024), # fetch first 128 KiB upfront
|
|
167
|
+
)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Synchronization driver (asyncio)
|
|
171
|
+
|
|
172
|
+
The same sync primitives, but fully async:
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
import asyncio
|
|
176
|
+
|
|
177
|
+
async def main():
|
|
178
|
+
conn = await turso.aio.sync.connect(":memory:", remote_url="https://<db>.<region>.turso.io")
|
|
179
|
+
|
|
180
|
+
# Read data
|
|
181
|
+
rows = await (await conn.execute("SELECT * FROM t")).fetchall()
|
|
182
|
+
print(rows)
|
|
183
|
+
|
|
184
|
+
# Pull and push
|
|
185
|
+
await conn.pull()
|
|
186
|
+
await conn.execute("INSERT INTO t VALUES ('hello from asyncio')")
|
|
187
|
+
await conn.commit()
|
|
188
|
+
await conn.push()
|
|
189
|
+
|
|
190
|
+
# Stats and maintenance
|
|
191
|
+
stats = await conn.stats()
|
|
192
|
+
print("Main WAL size:", stats.main_wal_size)
|
|
193
|
+
await conn.checkpoint()
|
|
194
|
+
|
|
195
|
+
await conn.close()
|
|
196
|
+
|
|
197
|
+
asyncio.run(main())
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
This project is licensed under the [MIT license](../../LICENSE.md).
|
|
203
|
+
|
|
204
|
+
## Support
|
|
205
|
+
|
|
206
|
+
- [GitHub Issues](https://github.com/tursodatabase/turso/issues)
|
|
207
|
+
- [Documentation](https://docs.turso.tech)
|
|
208
|
+
- [Discord Community](https://tur.so/discord)
|
|
209
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
pyturso-0.4.0rc9.dist-info/METADATA,sha256=DHbVWngxpHAls3Ix8qs-Tyt4-VsnhnMF2sla5EG0wAQ,6762
|
|
2
|
+
pyturso-0.4.0rc9.dist-info/WHEEL,sha256=SaNIiQNrtb_gMs98PxhWWAIwzEmQuCeBFXlGDceEcaU,147
|
|
3
|
+
turso/__init__.py,sha256=hHP6yAHO9k2sVxwkN0BgKyHyVgleQ8qnk5irv_3KAdk,674
|
|
4
|
+
turso/_turso.cpython-313-x86_64-linux-gnu.so,sha256=2nNaIvhUuIljZQEhIQ8F8icSIG9VD_ob4yyb4_DOmCw,45961272
|
|
5
|
+
turso/aio/__init__.py,sha256=AqixLRlMJgt9mO-L-WKDSuZ_W_jJ_hdGjTS0NVezXzg,112
|
|
6
|
+
turso/aio/sync/__init__.py,sha256=atfWoLQEfMQPKcamYfs9bbUerTs-OYqbYIg-_PXwaH8,293
|
|
7
|
+
turso/lib.py,sha256=w5rR8ugpZwog5Of88Jgc1wHZG-dDZ8Go_dAEOQx2qio,31592
|
|
8
|
+
turso/lib_aio.py,sha256=Qc-nw4yalXEOG9DdZUePpt9KouryJzGHgwQXBwWeCBU,12422
|
|
9
|
+
turso/lib_sync.py,sha256=NZnUBk9XkCkI68mQjrHd-OG8kA__YwoqeRFZbVgqT0s,15960
|
|
10
|
+
turso/lib_sync_aio.py,sha256=1JWIUKNZj-ExW9hlDcsSKbbBk7pDy-LGdNbH8hTDVic,3480
|
|
11
|
+
turso/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
turso/sync/__init__.py,sha256=7Dt7H5t64ylmmE_C6Gqo9Vm6a9u9CCQ0B74j_3TZMT0,287
|
|
13
|
+
turso/worker.py,sha256=zwV-PHe-VNNvuR_hepa6dzboF88DcjzA1MDQbMPE5qw,1499
|
|
14
|
+
pyturso-0.4.0rc9.dist-info/RECORD,,
|
turso/__init__.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from .lib import (
|
|
2
|
+
Connection,
|
|
3
|
+
Cursor,
|
|
4
|
+
DatabaseError,
|
|
5
|
+
DataError,
|
|
6
|
+
Error,
|
|
7
|
+
IntegrityError,
|
|
8
|
+
InterfaceError,
|
|
9
|
+
InternalError,
|
|
10
|
+
NotSupportedError,
|
|
11
|
+
OperationalError,
|
|
12
|
+
ProgrammingError,
|
|
13
|
+
Row,
|
|
14
|
+
Warning,
|
|
15
|
+
apilevel,
|
|
16
|
+
connect,
|
|
17
|
+
paramstyle,
|
|
18
|
+
setup_logging,
|
|
19
|
+
threadsafety,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"Connection",
|
|
24
|
+
"Cursor",
|
|
25
|
+
"Row",
|
|
26
|
+
"connect",
|
|
27
|
+
"setup_logging",
|
|
28
|
+
"Warning",
|
|
29
|
+
"DatabaseError",
|
|
30
|
+
"DataError",
|
|
31
|
+
"Error",
|
|
32
|
+
"IntegrityError",
|
|
33
|
+
"InterfaceError",
|
|
34
|
+
"InternalError",
|
|
35
|
+
"NotSupportedError",
|
|
36
|
+
"OperationalError",
|
|
37
|
+
"ProgrammingError",
|
|
38
|
+
"apilevel",
|
|
39
|
+
"paramstyle",
|
|
40
|
+
"threadsafety",
|
|
41
|
+
]
|
|
Binary file
|
turso/aio/__init__.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from ...lib_sync import (
|
|
2
|
+
PartialSyncOpts,
|
|
3
|
+
PartialSyncPrefixBootstrap,
|
|
4
|
+
PartialSyncQueryBootstrap,
|
|
5
|
+
)
|
|
6
|
+
from ...lib_sync_aio import (
|
|
7
|
+
connect_sync as connect,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"connect",
|
|
12
|
+
"PartialSyncOpts",
|
|
13
|
+
"PartialSyncPrefixBootstrap",
|
|
14
|
+
"PartialSyncQueryBootstrap",
|
|
15
|
+
]
|