Skip to content

sync_write.py example fails if local database does not exist #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
penberg opened this issue Apr 11, 2025 · 1 comment
Open

sync_write.py example fails if local database does not exist #88

penberg opened this issue Apr 11, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@penberg
Copy link
Contributor

penberg commented Apr 11, 2025

The example fails as follows if you remove the local database:

(.env) penberg@vonneumann libsql-experimental-python % python3 examples/sync_write.py
syncing with libsql://python-penberg.aws-eu-west-1.turso.io

thread '<unnamed>' panicked at /Users/penberg/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libsql-0.9.3/src/sync.rs:703:9:
generation should be > 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/Users/penberg/src/tursodatabase/libsql-experimental-python/examples/sync_write.py", line 16, in <module>
    conn.sync()
pyo3_runtime.PanicException: generation should be > 0

A call to sync() helps but should not be needed:

diff --git a/examples/sync_write.py b/examples/sync_write.py
index 853aa83..12f05ee 100644
--- a/examples/sync_write.py
+++ b/examples/sync_write.py
@@ -10,6 +10,7 @@ import libsql_experimental as libsql
 print(F"syncing with {os.getenv('LIBSQL_URL')}")
 conn = libsql.connect("hello.db", sync_url=os.getenv("LIBSQL_URL"),
                       auth_token=os.getenv("LIBSQL_AUTH_TOKEN"))
+conn.sync()
 conn.execute("CREATE TABLE IF NOT EXISTS users (id INTEGER);")
 conn.execute("INSERT INTO users(id) VALUES (1);")
 conn.commit()
@penberg penberg added the bug Something isn't working label Apr 11, 2025
@avinassh
Copy link
Member

fixed with the new release f4a34e7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants