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
refactor(turso): migrate from libsql-client to libsql package (#37)
* refactor(turso): migrate from libsql-client to libsql package
libsql-client is deprecated; switch to the new libsql package with
updated API patterns (connect instead of create_client_sync, cursor-based
query execution with fetchall/description instead of result.rows).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix(turso): use direct HTTP mode and add commit() for write persistence
The libsql package has two connection modes:
1. Embedded replica mode (local file + sync_url) - for read-heavy caching
2. Direct HTTP mode (url only) - for immediate read/write operations
The previous implementation used embedded replica mode which:
- Writes to a local temp file that gets deleted on close
- sync() only pulls FROM server, doesn't push writes back
- Missing commit() meant writes weren't persisted
This fix:
- Uses direct HTTP mode: libsql.connect(url, auth_token=token)
- Adds conn.commit() in execute_non_query() like all other adapters
- Converts libsql:// URLs to https:// as required by the package
Tested against both Turso Cloud and local Docker (libsql-server).
* fix(tests): update Turso fixtures to use direct HTTP mode
Update test fixtures to match the adapter's direct HTTP mode:
- _create_turso_connection() now uses libsql.connect(url, auth_token=token)
- _setup_turso_test_tables() uses commit() instead of sync()
- _cleanup_turso_test_tables() uses commit() instead of sync()
This ensures test setup/teardown works consistently with the adapter
for both Turso Cloud and local Docker environments.
* test(turso): add write persistence test and fix cloud mode handling
- Add test_write_persistence_across_connections() to verify writes
persist to the remote server across separate connections
- Fix test_create_turso_connection() to handle cloud mode (tuple)
- Fix test_delete_turso_connection() to handle cloud mode (tuple)
- Add test_expand_tables_folder(), test_expand_table_node(), and
test_expand_views_folder() to test tree expansion operations
The persistence test catches the bug where embedded replica mode
doesn't actually persist writes to the remote server.
* chore: add .env.example and protect secrets in tests/.env
- Add tests/.env to .gitignore to prevent accidental commit of secrets
- Add tests/.env.example as template for Turso Cloud configuration
To test against Turso Cloud instead of local Docker:
1. Copy tests/.env.example to tests/.env
2. Fill in your Turso Cloud URL and auth token
3. Run: pytest tests/test_turso.py -v
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Peter Adams <18162810+Maxteabag@users.noreply.github.com>
0 commit comments