This datasource is only available for Node.js agents.
Basic usage
Automatic schema introspection
By default, the SQL datasource automatically discovers your database structure when the back-end starts. It extracts:- Tables and views - Each becomes a collection
- Columns - With automatic type detection
- Primary keys - For record identification
- Foreign keys - Converted to relationships
- Indexes - Used for query optimization
information_schema. Ownership roles are recommended.
Introspection is supported for PostgreSQL, MySQL, MariaDB, and Microsoft SQL Server.
Configuration options
Connection URI
The connection URI format varies by database:SSL configuration
Control SSL/TLS connection behavior:preferred- Use SSL if available, otherwise unencrypted (default)required- Require SSL, fail if unavailableverify- Require SSL with certificate verificationdisabled- Never use SSLmanual- Custom SSL configuration (advanced)
Schema selection
Specify which database schema to use (PostgreSQL, SQL Server):Connection pooling
Configure connection pool for optimal performance:Read replicas
Distribute read operations across replica databases:SSH tunnel
Connect through an SSH tunnel:SOCKS5 proxy
Route connections through a SOCKS5 proxy:Connection timeout
Set maximum time to establish connection:Soft-deleted records
Display records marked as deleted (soft deletes):deleted_at column) and you want to manage deleted records in Forest.
Caching introspection
The schema introspection is JSON serializable. Cache it to a file:- Faster back-end startup (no introspection delay)
- Work offline or with restricted credentials
- Separate introspection and runtime credentials
- Version control your schema
Live Query support
Enable SQL-based reporting by setting a connection identifier:Supported databases
| Database | Versions | Driver Package | Status |
|---|---|---|---|
| PostgreSQL | 10+ | pg + pg-hstore | ✅ Full support (recommended) |
| MySQL | 5.7+ | mysql2 | ✅ Production-ready |
| MariaDB | 10+ | mariadb | ✅ Production-ready |
| SQL Server | 2017+ | tedious | ✅ Enterprise support |
Source code
This connector is open source. Browse the code or contribute on GitHub:@forestadmin/datasource-sql.