libsql 0.1.1__tar.gz → 0.1.3rc1__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 (47) hide show
  1. {libsql-0.1.1 → libsql-0.1.3rc1}/Cargo.lock +24 -21
  2. {libsql-0.1.1 → libsql-0.1.3rc1}/Cargo.toml +2 -2
  3. {libsql-0.1.1 → libsql-0.1.3rc1}/PKG-INFO +1 -1
  4. {libsql-0.1.1 → libsql-0.1.3rc1}/pyproject.toml +1 -1
  5. {libsql-0.1.1 → libsql-0.1.3rc1}/src/lib.rs +15 -4
  6. {libsql-0.1.1 → libsql-0.1.3rc1}/tests/test_suite.py +17 -12
  7. {libsql-0.1.1 → libsql-0.1.3rc1}/.github/workflows/CI.yml +0 -0
  8. {libsql-0.1.1 → libsql-0.1.3rc1}/.github/workflows/pr-tests.yml +0 -0
  9. {libsql-0.1.1 → libsql-0.1.3rc1}/.gitignore +0 -0
  10. {libsql-0.1.1 → libsql-0.1.3rc1}/CONTRIBUTING.md +0 -0
  11. {libsql-0.1.1 → libsql-0.1.3rc1}/LICENSE.md +0 -0
  12. {libsql-0.1.1 → libsql-0.1.3rc1}/README.md +0 -0
  13. {libsql-0.1.1 → libsql-0.1.3rc1}/build.rs +0 -0
  14. {libsql-0.1.1 → libsql-0.1.3rc1}/docs/api.md +0 -0
  15. {libsql-0.1.1 → libsql-0.1.3rc1}/example.py +0 -0
  16. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/batch/.gitignore +0 -0
  17. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/batch/README.md +0 -0
  18. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/batch/main.py +0 -0
  19. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/encryption/.gitignore +0 -0
  20. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/encryption/README.md +0 -0
  21. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/encryption/main.py +0 -0
  22. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/execute_script.py +0 -0
  23. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/local/.gitignore +0 -0
  24. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/local/README.md +0 -0
  25. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/local/main.py +0 -0
  26. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/memory/README.md +0 -0
  27. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/memory/main.py +0 -0
  28. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/remote/README.md +0 -0
  29. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/remote/main.py +0 -0
  30. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/remote_connect.py +0 -0
  31. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/sqlalchemy/dialect.py +0 -0
  32. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/sqlalchemy/example.py +0 -0
  33. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/statements.sql +0 -0
  34. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/sync/.gitignore +0 -0
  35. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/sync/README.md +0 -0
  36. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/sync/main.py +0 -0
  37. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/sync_write.py +0 -0
  38. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/transaction/.gitignore +0 -0
  39. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/transaction/README.md +0 -0
  40. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/transaction/main.py +0 -0
  41. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/vector/.gitignore +0 -0
  42. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/vector/README.md +0 -0
  43. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/vector/main.py +0 -0
  44. {libsql-0.1.1 → libsql-0.1.3rc1}/examples/vector.py +0 -0
  45. {libsql-0.1.1 → libsql-0.1.3rc1}/perf-libsql.py +0 -0
  46. {libsql-0.1.1 → libsql-0.1.3rc1}/perf-sqlite3.py +0 -0
  47. {libsql-0.1.1 → libsql-0.1.3rc1}/shell.nix +0 -0
@@ -326,6 +326,15 @@ dependencies = [
326
326
  "libloading",
327
327
  ]
328
328
 
329
+ [[package]]
330
+ name = "cmake"
331
+ version = "0.1.54"
332
+ source = "registry+https://github.com/rust-lang/crates.io-index"
333
+ checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0"
334
+ dependencies = [
335
+ "cc",
336
+ ]
337
+
329
338
  [[package]]
330
339
  name = "core-foundation"
331
340
  version = "0.9.4"
@@ -806,9 +815,8 @@ dependencies = [
806
815
 
807
816
  [[package]]
808
817
  name = "libsql"
809
- version = "0.9.10"
810
- source = "registry+https://github.com/rust-lang/crates.io-index"
811
- checksum = "2c9f529b1afe0465e1f864fa34cdcad08fb463a1bf86b40267493db83508ee9d"
818
+ version = "0.9.15"
819
+ source = "git+https://github.com/tursodatabase/libsql/?rev=57043b60f3db38236187a8905bee62b35bf18afb#57043b60f3db38236187a8905bee62b35bf18afb"
812
820
  dependencies = [
813
821
  "anyhow",
814
822
  "async-stream",
@@ -846,20 +854,19 @@ dependencies = [
846
854
 
847
855
  [[package]]
848
856
  name = "libsql-ffi"
849
- version = "0.9.10"
850
- source = "registry+https://github.com/rust-lang/crates.io-index"
851
- checksum = "739717a55160a200ef8a9122a17d559148ddd3f0c526b52b3908f9a80aca5284"
857
+ version = "0.9.15"
858
+ source = "git+https://github.com/tursodatabase/libsql/?rev=57043b60f3db38236187a8905bee62b35bf18afb#57043b60f3db38236187a8905bee62b35bf18afb"
852
859
  dependencies = [
853
860
  "bindgen",
854
861
  "cc",
862
+ "cmake",
855
863
  "glob",
856
864
  ]
857
865
 
858
866
  [[package]]
859
867
  name = "libsql-hrana"
860
- version = "0.9.10"
861
- source = "registry+https://github.com/rust-lang/crates.io-index"
862
- checksum = "44633324952c32e3ab7da5e5cf36af9d7afe53e74f811e622ef23207b357ff18"
868
+ version = "0.9.15"
869
+ source = "git+https://github.com/tursodatabase/libsql/?rev=57043b60f3db38236187a8905bee62b35bf18afb#57043b60f3db38236187a8905bee62b35bf18afb"
863
870
  dependencies = [
864
871
  "base64 0.21.7",
865
872
  "bytes",
@@ -869,9 +876,8 @@ dependencies = [
869
876
 
870
877
  [[package]]
871
878
  name = "libsql-rusqlite"
872
- version = "0.9.10"
873
- source = "registry+https://github.com/rust-lang/crates.io-index"
874
- checksum = "1d042d19c09bb858a4ca93c6ae346a8267215301e265097c2858a1c91f6384bd"
879
+ version = "0.9.15"
880
+ source = "git+https://github.com/tursodatabase/libsql/?rev=57043b60f3db38236187a8905bee62b35bf18afb#57043b60f3db38236187a8905bee62b35bf18afb"
875
881
  dependencies = [
876
882
  "bitflags 2.6.0",
877
883
  "fallible-iterator 0.2.0",
@@ -884,8 +890,7 @@ dependencies = [
884
890
  [[package]]
885
891
  name = "libsql-sqlite3-parser"
886
892
  version = "0.13.0"
887
- source = "registry+https://github.com/rust-lang/crates.io-index"
888
- checksum = "15a90128c708356af8f7d767c9ac2946692c9112b4f74f07b99a01a60680e413"
893
+ source = "git+https://github.com/tursodatabase/libsql/?rev=57043b60f3db38236187a8905bee62b35bf18afb#57043b60f3db38236187a8905bee62b35bf18afb"
889
894
  dependencies = [
890
895
  "bitflags 2.6.0",
891
896
  "cc",
@@ -901,9 +906,8 @@ dependencies = [
901
906
 
902
907
  [[package]]
903
908
  name = "libsql-sys"
904
- version = "0.9.10"
905
- source = "registry+https://github.com/rust-lang/crates.io-index"
906
- checksum = "3760d2141b2ac78a24c303c53ee0720301bbbe5158db3fc016c26f3eeeb44712"
909
+ version = "0.9.15"
910
+ source = "git+https://github.com/tursodatabase/libsql/?rev=57043b60f3db38236187a8905bee62b35bf18afb#57043b60f3db38236187a8905bee62b35bf18afb"
907
911
  dependencies = [
908
912
  "bytes",
909
913
  "libsql-ffi",
@@ -915,9 +919,8 @@ dependencies = [
915
919
 
916
920
  [[package]]
917
921
  name = "libsql_replication"
918
- version = "0.9.10"
919
- source = "registry+https://github.com/rust-lang/crates.io-index"
920
- checksum = "039dccb52999803f36bc850be4e2ebc6987d1fe622994df1678b87c849c9dca1"
922
+ version = "0.9.15"
923
+ source = "git+https://github.com/tursodatabase/libsql/?rev=57043b60f3db38236187a8905bee62b35bf18afb#57043b60f3db38236187a8905bee62b35bf18afb"
921
924
  dependencies = [
922
925
  "aes",
923
926
  "async-stream",
@@ -1227,7 +1230,7 @@ dependencies = [
1227
1230
 
1228
1231
  [[package]]
1229
1232
  name = "pylibsql"
1230
- version = "0.1.1"
1233
+ version = "0.1.3-pre.1"
1231
1234
  dependencies = [
1232
1235
  "libsql",
1233
1236
  "pyo3",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "pylibsql"
3
- version = "0.1.1"
3
+ version = "0.1.3-pre.1"
4
4
  edition = "2021"
5
5
 
6
6
  [lib]
@@ -8,7 +8,7 @@ crate-type = ["cdylib"]
8
8
 
9
9
  [dependencies]
10
10
  pyo3 = "0.19.0"
11
- libsql = { version = "0.9.10", features = ["encryption"] }
11
+ libsql = { git = "https://github.com/tursodatabase/libsql/", rev = "57043b60f3db38236187a8905bee62b35bf18afb", features = ["encryption"] }
12
12
  tokio = { version = "1.29.1", features = [ "rt-multi-thread" ] }
13
13
  tracing-subscriber = "0.3"
14
14
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libsql
3
- Version: 0.1.1
3
+ Version: 0.1.3rc1
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "libsql"
7
- version = "0.1.1"
7
+ version = "0.1.3-pre.1"
8
8
  requires-python = ">=3.7"
9
9
  classifiers = [
10
10
  "Programming Language :: Rust",
@@ -5,6 +5,7 @@ use pyo3::prelude::*;
5
5
  use pyo3::types::{PyList, PyTuple};
6
6
  use std::cell::{OnceCell, RefCell};
7
7
  use std::sync::{Arc, OnceLock};
8
+ use std::time::Duration;
8
9
  use tokio::runtime::{Handle, Runtime};
9
10
 
10
11
  const LEGACY_TRANSACTION_CONTROL: i32 = -1;
@@ -37,10 +38,11 @@ fn is_remote_path(path: &str) -> bool {
37
38
 
38
39
  #[pyfunction]
39
40
  #[cfg(not(Py_3_12))]
40
- #[pyo3(signature = (database, isolation_level="DEFERRED".to_string(), check_same_thread=true, uri=false, sync_url=None, sync_interval=None, auth_token="", encryption_key=None))]
41
+ #[pyo3(signature = (database, timeout=5.0, isolation_level="DEFERRED".to_string(), check_same_thread=true, uri=false, sync_url=None, sync_interval=None, auth_token="", encryption_key=None))]
41
42
  fn connect(
42
43
  py: Python<'_>,
43
44
  database: String,
45
+ timeout: f64,
44
46
  isolation_level: Option<String>,
45
47
  check_same_thread: bool,
46
48
  uri: bool,
@@ -52,6 +54,7 @@ fn connect(
52
54
  let conn = _connect_core(
53
55
  py,
54
56
  database,
57
+ timeout,
55
58
  isolation_level,
56
59
  check_same_thread,
57
60
  uri,
@@ -65,10 +68,11 @@ fn connect(
65
68
 
66
69
  #[pyfunction]
67
70
  #[cfg(Py_3_12)]
68
- #[pyo3(signature = (database, isolation_level="DEFERRED".to_string(), check_same_thread=true, uri=false, sync_url=None, sync_interval=None, auth_token="", encryption_key=None, autocommit = LEGACY_TRANSACTION_CONTROL))]
71
+ #[pyo3(signature = (database, timeout=5.0, isolation_level="DEFERRED".to_string(), check_same_thread=true, uri=false, sync_url=None, sync_interval=None, auth_token="", encryption_key=None, autocommit = LEGACY_TRANSACTION_CONTROL))]
69
72
  fn connect(
70
73
  py: Python<'_>,
71
74
  database: String,
75
+ timeout: f64,
72
76
  isolation_level: Option<String>,
73
77
  check_same_thread: bool,
74
78
  uri: bool,
@@ -81,6 +85,7 @@ fn connect(
81
85
  let mut conn = _connect_core(
82
86
  py,
83
87
  database,
88
+ timeout,
84
89
  isolation_level.clone(),
85
90
  check_same_thread,
86
91
  uri,
@@ -104,6 +109,7 @@ fn connect(
104
109
  fn _connect_core(
105
110
  py: Python<'_>,
106
111
  database: String,
112
+ timeout: f64,
107
113
  isolation_level: Option<String>,
108
114
  check_same_thread: bool,
109
115
  uri: bool,
@@ -130,8 +136,11 @@ fn _connect_core(
130
136
  match sync_url {
131
137
  Some(sync_url) => {
132
138
  let sync_interval = sync_interval.map(|i| std::time::Duration::from_secs_f64(i));
133
- let mut builder =
134
- libsql_core::Builder::new_remote_replica(database, sync_url, auth_token.to_string());
139
+ let mut builder = libsql_core::Builder::new_remote_replica(
140
+ database,
141
+ sync_url,
142
+ auth_token.to_string(),
143
+ );
135
144
  if let Some(encryption_config) = encryption_config {
136
145
  builder = builder.encryption_config(encryption_config);
137
146
  }
@@ -158,6 +167,8 @@ fn _connect_core(
158
167
 
159
168
  let autocommit = isolation_level.is_none() as i32;
160
169
  let conn = db.connect().map_err(to_py_err)?;
170
+ let timeout = Duration::from_secs_f64(timeout);
171
+ conn.busy_timeout(timeout).map_err(to_py_err)?;
161
172
  Ok(Connection {
162
173
  db,
163
174
  conn: RefCell::new(Some(Arc::new(ConnectionGuard {
@@ -4,7 +4,12 @@ import sqlite3
4
4
  import sys
5
5
  import libsql
6
6
  import pytest
7
+ import tempfile
7
8
 
9
+ @pytest.mark.parametrize("provider", ["libsql", "sqlite"])
10
+ def test_connection_timeout(provider):
11
+ conn = connect(provider, ":memory:", timeout=1.0)
12
+ conn.close()
8
13
 
9
14
  @pytest.mark.parametrize("provider", ["libsql", "sqlite"])
10
15
  def test_connection_close(provider):
@@ -163,7 +168,7 @@ def test_commit_and_rollback(provider):
163
168
 
164
169
  @pytest.mark.parametrize("provider", ["libsql", "sqlite"])
165
170
  def test_autocommit(provider):
166
- conn = connect(provider, ":memory:", None)
171
+ conn = connect(provider, ":memory:", timeout=4, isolation_level=None)
167
172
  assert conn.isolation_level == None
168
173
  assert conn.in_transaction == False
169
174
  cur = conn.cursor()
@@ -182,7 +187,7 @@ def test_autocommit(provider):
182
187
  @pytest.mark.skipif(sys.version_info < (3, 12), reason="requires python3.12 or higher")
183
188
  def test_connection_autocommit(provider):
184
189
  # Test LEGACY_TRANSACTION_CONTROL (-1)
185
- conn = connect(provider, ":memory:", None, autocommit=-1)
190
+ conn = connect(provider, ":memory:", timeout=5, isolation_level=None, autocommit=-1)
186
191
  assert conn.isolation_level is None
187
192
  assert conn.autocommit == -1
188
193
  cur = conn.cursor()
@@ -193,7 +198,7 @@ def test_connection_autocommit(provider):
193
198
  res = cur.execute("SELECT * FROM users")
194
199
  assert (1, "alice@example.com") == res.fetchone()
195
200
 
196
- conn = connect(provider, ":memory:", isolation_level="DEFERRED", autocommit=-1)
201
+ conn = connect(provider, ":memory:", timeout=5, isolation_level="DEFERRED", autocommit=-1)
197
202
  assert conn.isolation_level == "DEFERRED"
198
203
  assert conn.autocommit == -1
199
204
  cur = conn.cursor()
@@ -205,7 +210,7 @@ def test_connection_autocommit(provider):
205
210
  assert (1, "alice@example.com") == res.fetchone()
206
211
 
207
212
  # Test autocommit Enabled (True)
208
- conn = connect(provider, ":memory:", None, autocommit=True)
213
+ conn = connect(provider, ":memory:", timeout=5, isolation_level=None, autocommit=True)
209
214
  assert conn.isolation_level == None
210
215
  assert conn.autocommit == True
211
216
  cur = conn.cursor()
@@ -216,7 +221,7 @@ def test_connection_autocommit(provider):
216
221
  res = cur.execute("SELECT * FROM users")
217
222
  assert (1, "bob@example.com") == res.fetchone()
218
223
 
219
- conn = connect(provider, ":memory:", isolation_level="DEFERRED", autocommit=True)
224
+ conn = connect(provider, ":memory:", timeout=5, isolation_level="DEFERRED", autocommit=True)
220
225
  assert conn.isolation_level == "DEFERRED"
221
226
  assert conn.autocommit == True
222
227
  cur = conn.cursor()
@@ -228,7 +233,7 @@ def test_connection_autocommit(provider):
228
233
  assert (1, "bob@example.com") == res.fetchone()
229
234
 
230
235
  # Test autocommit Disabled (False)
231
- conn = connect(provider, ":memory:", isolation_level="DEFERRED", autocommit=False)
236
+ conn = connect(provider, ":memory:", timeout=5, isolation_level="DEFERRED", autocommit=False)
232
237
  assert conn.isolation_level == "DEFERRED"
233
238
  assert conn.autocommit == False
234
239
  cur = conn.cursor()
@@ -243,7 +248,7 @@ def test_connection_autocommit(provider):
243
248
 
244
249
  # Test invalid autocommit value (should raise an error)
245
250
  with pytest.raises(ValueError):
246
- connect(provider, ":memory:", None, autocommit=999)
251
+ connect(provider, ":memory:", timeout=5, isolation_level=None, autocommit=999)
247
252
 
248
253
 
249
254
  @pytest.mark.parametrize("provider", ["libsql", "sqlite"])
@@ -316,7 +321,7 @@ def test_int64(provider):
316
321
  assert [(1, 1099511627776)] == res.fetchall()
317
322
 
318
323
 
319
- def connect(provider, database, isolation_level="DEFERRED", autocommit=-1):
324
+ def connect(provider, database, timeout=5, isolation_level="DEFERRED", autocommit=-1):
320
325
  if provider == "libsql-remote":
321
326
  from urllib import request
322
327
 
@@ -332,21 +337,21 @@ def connect(provider, database, isolation_level="DEFERRED", autocommit=-1):
332
337
  if provider == "libsql":
333
338
  if sys.version_info < (3, 12):
334
339
  return libsql.connect(
335
- database, isolation_level=isolation_level
340
+ database, timeout=timeout, isolation_level=isolation_level
336
341
  )
337
342
  else:
338
343
  if autocommit == -1:
339
344
  autocommit = libsql.LEGACY_TRANSACTION_CONTROL
340
345
  return libsql.connect(
341
- database, isolation_level=isolation_level, autocommit=autocommit
346
+ database, timeout=timeout, isolation_level=isolation_level, autocommit=autocommit
342
347
  )
343
348
  if provider == "sqlite":
344
349
  if sys.version_info < (3, 12):
345
- return sqlite3.connect(database, isolation_level=isolation_level)
350
+ return sqlite3.connect(database, timeout=timeout, isolation_level=isolation_level)
346
351
  else:
347
352
  if autocommit == -1:
348
353
  autocommit = sqlite3.LEGACY_TRANSACTION_CONTROL
349
354
  return sqlite3.connect(
350
- database, isolation_level=isolation_level, autocommit=autocommit
355
+ database, timeout=timeout, isolation_level=isolation_level, autocommit=autocommit
351
356
  )
352
357
  raise Exception(f"Provider `{provider}` is not supported")
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