You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importosimportlibsql_experimentalaslibsqlprint(F"connecting to {os.getenv('LIBSQL_URL')}")
conn=libsql.connect(database=os.getenv('LIBSQL_URL'), sync_url=os.getenv("LIBSQL_URL"),
auth_token=os.getenv("LIBSQL_AUTH_TOKEN"))
conn.execute("CREATE TABLE IF NOT EXISTS users_sync (id INTEGER);")
conn.execute("INSERT INTO users_sync(id) VALUES (10);")
conn.commit()
print(conn.execute("select * from users_sync").fetchall())
I'm getting the same error in Go. Some more info based off the below code:
If you remove the SELECT * FROM users_sync chunk of code it works fine. And it returns the proper results if you move that SELECT out of the transaction.
It works fine against a sqld image running in Docker just fine.
package main
import (
"context""database/sql""fmt""os"
_ "github.com/tursodatabase/libsql-client-go/libsql"
)
funcmain() {
db, err:=sql.Open("libsql", os.Getenv("LIBSQL_URL"))
iferr!=nil {
fmt.Fprintf(os.Stderr, "failed to open db %s", err)
os.Exit(1)
}
deferdb.Close()
tx, err:=db.BeginTx(context.Background(), &sql.TxOptions{})
iferr!=nil {
panic(err)
}
_, err=tx.Exec("CREATE TABLE IF NOT EXISTS users_sync (id INTEGER)")
iferr!=nil {
panic(err)
}
_, err=tx.Exec("INSERT INTO users_sync(id) VALUES (10)")
iferr!=nil {
panic(err)
}
rows, err:=tx.Query("SELECT * FROM users_sync")
iferr!=nil {
panic(err)
}
deferrows.Close()
forrows.Next() {
varidintiferr:=rows.Scan(&id); err!=nil {
fmt.Println("Error scanning row:", err)
return
}
fmt.Println("id:", id)
}
err=tx.Commit()
iferr!=nil {
panic(err)
}
}
And I confirmed with my project code where I'm getting this during my account provisioning routine that if I remove all of the selects I don't get this error.
Python SQLite interface expects caller to call
commit()
explicitly but @avinassh points out this does not work with remote databases:I am guessing the remote protocol semantics with
is_autocommit()
are wrong in libsql crate.The text was updated successfully, but these errors were encountered: