DATABASE_URL environment variable to connect to your database. The format varies depending on the database type.
PostgreSQL
PostgreSQL supports multiple URL schemes:postgres://, postgresql://, or psql://
Format
Examples
Common Options
sslmode- SSL mode (disable, require, verify-ca, verify-full)connect_timeout- Connection timeout in secondsapplication_name- Application name for connection tracking
MySQL
MySQL uses themysql:// scheme.
Format
Examples
Common Options
charset- Character set (utf8mb4 recommended)parseTime- Parse DATE and DATETIME to time.Timeloc- Location for time.Time values
The default port for MySQL is
3306.MariaDB
MariaDB uses themariadb:// scheme and has a similar format to MySQL.
Format
Examples
SQLite
SQLite uses file-based databases with thesqlite:// or sqlite3:// scheme.
Format
Examples
If the SQLite database file doesn’t exist, Geni will automatically create it when running migrations or using
geni create.Path Guidelines
- Use
./prefix for relative paths:sqlite://./data/app.db - Use
/prefix for absolute paths:sqlite:///home/user/app.db - Geni creates parent directories automatically if they don’t exist
LibSQL
LibSQL (including Turso) uses HTTP/HTTPS protocols for remote databases.Format
Examples
Authentication
LibSQL and Turso databases often require authentication. Set theDATABASE_TOKEN environment variable:
- Local LibSQL servers typically use HTTP (
http://localhost:8080) - Turso databases always use HTTPS (
https://) - If
DATABASE_TOKENis not set, Geni attempts to connect without authentication
URL Encoding
Special characters in passwords must be URL-encoded:| Character | Encoded |
|---|---|
| @ | %40 |
| : | %3A |
| / | %2F |
| ? | %3F |
| # | %23 |
| & | %26 |
| = | %3D |
| + | %2B |
| (space) | %20 |
Example
If your password isp@ssw0rd!, encode it as:
Testing Database URLs
Here are the database URLs used in Geni’s integration tests:Troubleshooting
Connection Failed
Database not found
Database not found
Ensure the database exists. Use
geni create to create it (works for PostgreSQL, MySQL, and MariaDB):Authentication failed
Authentication failed
- Verify username and password are correct
- Check for special characters that need URL encoding
- For LibSQL/Turso, ensure
DATABASE_TOKENis set correctly
Connection timeout
Connection timeout
- Verify the host and port are correct
- Check if the database server is running
- Increase
DATABASE_WAIT_TIMEOUTif the database is slow to start
SSL/TLS errors (PostgreSQL)
SSL/TLS errors (PostgreSQL)
For local development, disable SSL:For production, use appropriate SSL mode:
sslmode=require- Require SSLsslmode=verify-ca- Verify certificate authoritysslmode=verify-full- Verify certificate and hostname
Supported URL Schemes
Geni recognizes the following URL schemes for database detection:| Database | Supported Schemes |
|---|---|
| PostgreSQL | postgres://, postgresql://, psql:// |
| MySQL | mysql:// |
| MariaDB | mariadb:// |
| SQLite | sqlite://, sqlite3:// |
| LibSQL/Turso | http://, https://, libsql:// |