Database Integration
The Database Integration connects Reflex Build apps to an existing SQL database. When you enable the connection for an app, Reflex Build can inspect its schema and use that structure while generating the app.
Supported Databases
- PostgreSQL
- MySQL
- MSSQL (Microsoft SQL Server)
- SQLite
Add a Database Integration
- Open Integrations from the project sidebar.
- Select Add Integration.
- Search for and select Database.
- Configure the connection using Connection Details or Database URI.
- Optionally enter an integration name to distinguish this connection from others in the project.
- Select Save Changes.
The integration is saved at the project level. Open an app's Integrations panel to enable it for that app when needed.
Connection Details
Use Connection Details to enter each part of the connection separately.
For PostgreSQL, MySQL, and MSSQL, choose the database type and enter:
hostname: the database server address.port: defaults to5432for PostgreSQL,3306for MySQL, or1433for MSSQL.usernameandpassword: the database credentials.database_name: the database to connect to.
For MSSQL, Trust Server Certificate skips certificate identity validation. Use it only as a temporary workaround for an untrusted or self-signed server certificate, and prefer configuring a certificate that the client trusts.
For SQLite, select SQLite and enter an HTTP or HTTPS SQLite Download URL. Reflex Build downloads the database file before using it.
Database URI
Use Database URI when you have a complete connection URI for one of the supported database types. For example:
Enter the URI in db_url, then select Save Changes. Reflex Build selects the database driver automatically. Include provider-required connection options as query parameters when needed.
Connect through an SSH Tunnel
Use an SSH tunnel when the database is on a private network but can be reached through a bastion host. This option is available for PostgreSQL, MySQL, and MSSQL in both connection modes. It is not available for SQLite.
- Enter the database connection details or URI. Keep the database hostname and port set to the address the bastion host uses to reach the database.
- Turn on Connect via SSH tunnel.
- Enter the
ssh_hostname,ssh_port(usually22), andssh_usernamefor the bastion host. - Paste the corresponding PEM-formatted SSH private key.
- Select Save Changes.
The SSH account must allow port forwarding to the database host and port. Use a dedicated, restricted SSH key and database user for Reflex Build.
Enable the Integration for an App
Open the app's Integrations panel and enable the saved database connection. Reflex Build then connects to the database and, when the app does not already have a model file, creates the app's data models from the schema.
If the connection fails, check that:
- The database or bastion host is reachable.
- The ports are open and the credentials are valid.
- The database user can read the schema and has only the data permissions the app needs.
- The SSH user can forward traffic to the database when tunneling is enabled.