Database Connections 🔌¶
Jetbase supports multiple databases. This guide covers how to connect to each supported database using a SQLAlchemy url.
PostgreSQL¶
PostgreSQL is a popular open-source relational database and is fully supported by Jetbase.
Installing a Driver¶
PostgreSQL requires a database driver. Examples:
Connection String¶
Example¶
With a specific schema:
# jetbase/env.py
sqlalchemy_url = "postgresql://myuser:mypassword@localhost:5432/myapp"
postgres_schema = "public"
Snowflake¶
Snowflake is a cloud-based data warehouse. Jetbase supports both username/password and key pair authentication.
Installing the Driver¶
Snowflake requires additional dependencies. Install Jetbase with the Snowflake extra:
Connection String Format¶
| Component | Description |
|---|---|
username |
Your Snowflake username |
password |
Your Snowflake password (omit for key pair auth) |
account |
Your Snowflake account identifier (e.g., abc12345.us-east-1) |
database |
Target database name |
schema |
Target schema name |
warehouse |
Compute warehouse to use |
Username & Password Authentication¶
The simplest way to connect is with username and password:
# jetbase/env.py
sqlalchemy_url = "snowflake://myuser:mypassword@myaccount.us-east-1/my_db/public?warehouse=COMPUTE_WH"
Key Pair Authentication¶
For enhanced security, Snowflake supports key pair authentication. To use it, omit the password from your connection string and configure your private key.
Step 1: Create a connection string without a password:
# jetbase/env.py
sqlalchemy_url = "snowflake://myuser@myaccount.us-east-1/my_db/public?warehouse=COMPUTE_WH"
Step 2: Configure your private key as an environment variable:
# Set the private key (PEM format)
export JETBASE_SNOWFLAKE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASC...
-----END PRIVATE KEY-----"
# Optional: if your private key is encrypted
export JETBASE_SNOWFLAKE_PRIVATE_KEY_PASSWORD="your-key-password"
Tip
It's best to read your private key file directly into the environment variable locally:
SQLite¶
SQLite is a lightweight, file-based database. It's great for development, testing, or small applications.
Connection String¶
SQLite doesn't require any additional drivers. Just connect with the connection string.
Examples¶
Relative path (relative to where you run Jetbase):
In-memory database (useful for testing):