Skip to content

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

@penberg

Description

@penberg

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions