Connection URL Format
LibSQL requires remote database URLs using HTTP/HTTPS protocols:Setup
Set your database URL and token
The token is optional for local LibSQL instances but required for Turso.
Configuration Examples
- Turso
- Local LibSQL Server
- Self-Hosted LibSQL
Features
Authentication
LibSQL supports token-based authentication. If no token is provided, Geni uses an empty string (source:libsql.rs:26-31):
Transaction Support
LibSQL migrations run in transactions by default usingexecute_transactional_batch. To disable transactions:
Schema Dumping
Geni automatically dumps your LibSQL schema after each successful migration by queryingsqlite_master:
- Tables
- Indexes
- Views
- Triggers
libsql.rs:196-214).
Connection Check
Unlike SQLite, LibSQL supports connection readiness checks:DATABASE_WAIT_TIMEOUT (source: libsql.rs:170-177).
Database Operations
Create Database
Not supported. Create databases through Turso CLI or your LibSQL provider:Drop Database
Not supported. Drop databases through your provider’s interface:Check Status
Limitations
No Database Management
LibSQL databases must be created and dropped through your provider’s interface (Turso CLI, web dashboard, etc.). Geni only handles migrations (source:libsql.rs:149-167).
Remote Only
Thelibsql:// scheme cannot be used for local file paths. This validation prevents common mistakes:
libsql.rs:25-38
Token Security
Tokens are sensitive credentials. Always:- Store tokens in environment variables, never in code
- Use secret management in CI/CD (GitHub Secrets, etc.)
- Rotate tokens periodically
- Use different tokens for development and production
Examples
Basic Migration
Create a table in20240115120000_create_users.up.sql:
20240115120000_create_users.down.sql:
LibSQL-Specific Features
LibSQL supports SQLite syntax plus some extensions:Turso Integration
Using Geni with Turso in a deployment workflow:Library Usage
Using Geni programmatically with LibSQL:Troubleshooting
Authentication Errors
If you see authentication errors:- Verify your
DATABASE_TOKENis correct - Check token hasn’t expired
- Ensure token has appropriate permissions
- For Turso, regenerate token:
turso db tokens create my-database
Connection Issues
If migrations fail to connect:- Verify the database URL is correct
- Check network connectivity to the LibSQL server
- Ensure the database exists (create via Turso CLI if needed)
- Try increasing
DATABASE_WAIT_TIMEOUT
URL Scheme Errors
If you see “libsql:// should only be used with remote database”:- Use
sqlite://for local files - Use
http://,https://, orlibsql://for remote databases - Check for typos in the URL
Migration Table
Geni creates aschema_migrations table:
Best Practices
- Store tokens in environment variables or secret managers
- Use different databases for development, staging, and production
- Enable foreign keys in migrations:
PRAGMA foreign_keys = ON - Test migrations locally with SQLite before deploying to LibSQL
- Keep schema dump in version control for collaboration
- Use Turso CLI for database creation and management
Turso Quick Start
Setup with Turso in 3 steps:When to Use LibSQL
Good for:- Serverless applications
- Edge deployments
- Globally distributed databases
- Applications using Turso
- SQLite compatibility with remote access
- Low-latency edge reads
- Local development (use SQLite instead)
- Applications without network access
- Use cases requiring traditional SQL servers