scs
scs copied to clipboard
Usage with TursoDB
Turso
Turso is a DBaaS based on libsql. They provide their own sdk kit for Go.
Issue
When I tried using sqlite3store I kept getting errors due the insert syntax.
This can be reproduced with the example from sqlite3store.go
.
2024/05/11 05:30:24 failed to execute SQL: SELECT data FROM sessions WHERE token = $1 AND julianday('now') < expiry Arguments do not match SQL parameters: value for parameter $1 not found
Note that this is only happening when I create an instance of sqlite3store
passing a db connection created with the import of turso sdk (_ "github.com/tursodatabase/libsql-client-go/libsql"
) then assigning it to sessionManager.store
.
So after an embarrasing amount of hours, I was able finally to debug what's going on (I'm on my joruney of learning Go).
I went ahead an copied inside my own files a copy of sqlite3store.go
and modified every named placeholder for positional placeholders and suddenly everything works as expected on Turso.
So I guess my question is, is there any risk on creating a PR to change $<number>
for ?
's for sqlite3store.go
?
After this changes, I can connect and work just fine using either a turso or local database. However that's as far as I tested.
Another option would be maybe create a PR with a new session store for Turso exclusively, but given the changes needed are small maybe it's just better to keep one store.
In any case, for the time being I'll just use my modified version.
Thanks for this. I was running into the same problem, and your solution worked. Looks like there's a PR already open for this actually #193
It'd be great if we could get this merged @alexedwards 🙏