Overview
Each VizBoard project can have multiple database connections. When you add a connection:- Credentials are encrypted using AES-256 encryption
- Connection validity is automatically tested
- Database schema is introspected and cached
- You can create widgets using tables from connected databases
Currently, VizBoard supports PostgreSQL databases only. Support for additional databases may be added in future releases.
Adding a Database Connection
You can add database connections when creating a new project or editing an existing one.Navigate to Project Form
For New Projects:
- Go to
/projectsand click “New Project” - Or click the “Create Project” button in the navigation
- Navigate to your project
- Click “Edit Project” in the project settings
Add Database Connection
In the project form, locate the “Database Connections” section and click “Add Connection”.Fill in the connection details:
A friendly name for this connection (e.g., “Production DB”, “Analytics”)
The database server hostname or IP address (e.g.,
localhost, db.example.com)PostgreSQL port number (default:
5432)The database name to connect to
Database username with read permissions
Database password (encrypted before storage)
Save and Validate
When you save the project, VizBoard will:
- Encrypt credentials using AES-256 (
src/app/actions/project/crud.ts:57-64) - Validate connection by attempting to connect to the database
- Introspect schema to discover tables and columns
- Store schema in the database for quick access
Connection Form Example
Here’s an example of a valid PostgreSQL connection:How Connections Are Stored
Database connections are stored securely in thedbconnections table.
Database Schema
Credential Encryption
Credentials are encrypted before storage (src/app/actions/project/crud.ts:57-65):
encrypt() function uses AES-256 encryption with a secret key from environment variables.
Connection Validation
After creating or updating connections, VizBoard automatically validates them.Validation Process
Connection Test
VizBoard attempts to establish a connection to the database using the provided credentials.
Update Status
The
isValid field is updated:true- Connection successfulfalse- Connection failednull- Not yet validated
Validation Code Reference
Connections are validated silently after creation (src/app/actions/project/crud.ts:80-89):
Schema Introspection
For valid connections, VizBoard automatically introspects the database schema.What is Introspected
- Tables: All tables in the database
- Columns: Column names, data types, and constraints
- Primary Keys: Identified for each table
- Foreign Keys: Relationships between tables
Introspection Flow
Trigger Introspection
After successful validation, VizBoard calls
CreateDbSchema(connectionId) for each valid connection.Fetch Schema
The function makes a request to
/api/createschema which:- Connects to the database
- Queries
information_schematables - Builds a complete schema representation
Store Schema
The schema is stored as JSON in the
dbSchema field with a timestamp in lastIntrospectionAt.Schema Introspection Code
Fromsrc/app/actions/project/database.ts:3-42:
Auto-Introspection
Schema introspection happens automatically in these scenarios:- When creating a project with new connections
- When updating a project and adding/modifying connections
- When manually regenerating schemas via the UI
Introspection runs in parallel for multiple connections to improve performance (
src/app/actions/project/crud.ts:102-134).Managing Connections
Updating a Connection
Modify Connection
Update any connection fields as needed. For security, the password field is always blank in the edit form.To keep the existing password, leave the password field as
KEEP_CURRENT_PASSWORD.Password Management
When editing connections, passwords are handled specially (src/app/actions/project/crud.ts:258-281):
Deleting a Connection
To remove a connection from a project:Regenerating Schemas
If your database schema changes (new tables, columns, etc.), you can regenerate the cached schema.Manual Regeneration
Programmatic Regeneration
TheregenerateProjectSchemas function handles schema regeneration (src/app/actions/project/crud.ts:685-782):
Multiple Connections Per Project
VizBoard supports multiple database connections in a single project.Use Cases
Multi-Database Analytics
Connect to multiple databases (e.g., production, staging) and create widgets from each
Cross-Database Dashboards
Build dashboards that pull data from different sources (e.g., sales DB, inventory DB)
Read Replicas
Connect to read replicas to reduce load on primary databases
Data Warehouse + App DB
Combine data from your application database and data warehouse
Widget-Connection Association
Each widget specifies which connection to use via theconnectionId field in its configuration.
connectionId is specified, widgets use the first available connection in the project.
Troubleshooting
Connection Validation Fails
Symptoms: Red badge on connection,isValid: false
Solutions:
- Verify hostname, port, and database name are correct
- Check that the database user has SELECT permissions
- Ensure the database server allows connections from VizBoard’s IP
- Check firewall rules and network security groups
- Verify password is correct (try connecting with
psqlor another client)
Schema Introspection Fails
Symptoms: Connection valid butdbSchema is null
Solutions:
- Check that the user has permissions to query
information_schema - Verify the database contains tables
- Try regenerating schemas manually
- Check server logs for detailed error messages
Connection Errors in Widgets
Symptoms: Widgets show “Unable to load data” Solutions:- Ensure the connection is valid (green badge)
- Verify the table name exists in the database
- Check that schema introspection completed successfully
- Regenerate schemas if database structure changed
”No valid connections” Error
Symptoms: Cannot make project public Context: Projects require at least one valid connection to be made public. Solutions:- Fix any invalid connections in the project
- Ensure at least one connection has
isValid: true - Re-validate connections by editing and saving the project
Security Best Practices
Use Read-Only Users
Create database users with SELECT-only permissions for VizBoard connections
Limit Network Access
Use IP whitelisting or VPN to restrict database access
Rotate Credentials
Periodically update database passwords and update connections
Monitor Access
Enable database audit logs to track query activity
