Skip to content

Manual Configuration

When zero-config auto-discovery isn't available for your environment, DevDb Pro supports manual configuration via a .devdbrc file.

When to Use Manual Configuration

Use a .devdbrc configuration file when:

  • Your environment isn't supported by zero-config
  • You have custom database setups
  • You need to connect to remote databases
  • Your credentials are stored in non-standard locations
  • You want to connect to multiple databases explicitly

Configuration File Location

Create a .devdbrc file in your project root (workspace root):

my-project/
├── .devdbrc          ← Configuration file
├── src/
├── package.json
└── ...

File Format

The .devdbrc file is a JSON array of database connection objects:

json
[
  {
    "name": "My Database",
    "type": "mysql",
    "host": "127.0.0.1",
    "port": "3306",
    "username": "root",
    "password": "secret",
    "database": "myapp"
  }
]

Configuration Helpers

DevDb provides tools to make configuration easy:

JSON Schema Validation

The .devdbrc file has automatic validation:

  • Real-time error checking
  • Required field indicators
  • Type validation

IntelliSense Support

DevDb provides intelligent autocompletion:

  • All available fields
  • Database types
  • Valid values

Snippets

Quick configuration templates:

SnippetDescription
devdb mysqlMySQL configuration
devdb mariadbMariaDB configuration
devdb postgresPostgreSQL configuration
devdb sqliteSQLite configuration
devdb mssqlMicrosoft SQL Server configuration

Usage:

  1. Create .devdbrc file
  2. Type snippet name (e.g., devdb mysql)
  3. Press Tab
  4. Fill in your credentials

Database-Specific Configuration

MySQL / MariaDB

json
{
  "name": "My MySQL Database",
  "type": "mysql",
  "host": "127.0.0.1",
  "port": "3306",
  "username": "root",
  "password": "secret",
  "database": "myapp"
}

Optional Fields:

json
{
  "options": {
    "connectTimeout": 10000,
    "ssl": {
      "rejectUnauthorized": false
    }
  }
}

PostgreSQL

json
{
  "name": "My PostgreSQL Database",
  "type": "postgres",
  "host": "localhost",
  "port": "5432",
  "username": "postgres",
  "password": "secret",
  "database": "myapp"
}

Optional Fields:

json
{
  "options": {
    "ssl": true,
    "connectionTimeoutMillis": 5000
  }
}

SQLite

json
{
  "name": "My SQLite Database",
  "type": "sqlite",
  "path": "/absolute/path/to/database.sqlite"
}

Relative Paths

For portability, use workspace-relative paths:

json
{
  "type": "sqlite",
  "path": "${workspaceFolder}/database/app.db"
}

Microsoft SQL Server

json
{
  "name": "My MSSQL Database",
  "type": "mssql",
  "host": "localhost",
  "port": "1433",
  "username": "sa",
  "password": "YourPassword123",
  "database": "master"
}

Common Options:

json
{
  "options": {
    "trustServerCertificate": true,
    "encrypt": true,
    "instanceName": "SQLEXPRESS"
  }
}

Multiple Connections

Configure multiple databases in a single file:

json
[
  {
    "name": "Main Database",
    "type": "mysql",
    "host": "127.0.0.1",
    "port": "3306",
    "username": "root",
    "password": "secret",
    "database": "main_db"
  },
  {
    "name": "Analytics Database",
    "type": "postgres",
    "host": "localhost",
    "port": "5432",
    "username": "postgres",
    "password": "secret",
    "database": "analytics"
  },
  {
    "name": "Cache Database",
    "type": "sqlite",
    "path": "${workspaceFolder}/cache.db"
  }
]

All databases appear in the DevDb sidebar.

Environment Variables

Use environment variables for sensitive data:

Using VS Code Variables

json
{
  "type": "mysql",
  "host": "${env:DB_HOST}",
  "port": "${env:DB_PORT}",
  "username": "${env:DB_USER}",
  "password": "${env:DB_PASSWORD}",
  "database": "${env:DB_NAME}"
}

Supported Variable Patterns

PatternDescriptionExample
${workspaceFolder}Workspace root path/path/to/project
${env:VAR_NAME}Environment variable${env:DB_HOST}
${env:VAR_NAME:default}With fallback${env:DB_HOST:localhost}

Security Best Practices

Don't Commit Credentials

Add .devdbrc to .gitignore:

bash
# .gitignore
.devdbrc

Use Environment Variables

Store credentials in environment variables:

  1. Create .env (also in .gitignore):
env
DB_HOST=127.0.0.1
DB_USER=root
DB_PASSWORD=secret
DB_NAME=myapp
  1. Reference in .devdbrc:
json
{
  "type": "mysql",
  "host": "${env:DB_HOST}",
  "username": "${env:DB_USER}",
  "password": "${env:DB_PASSWORD}",
  "database": "${env:DB_NAME}"
}

Share Configuration Template

Create .devdbrc.example for your team:

json
[
  {
    "name": "Main Database",
    "type": "mysql",
    "host": "${env:DB_HOST}",
    "port": "3306",
    "username": "${env:DB_USER}",
    "password": "${env:DB_PASSWORD}",
    "database": "${env:DB_NAME}"
  }
]

Commit this and document required environment variables in README.

Remote Databases

SSH Tunnel

For databases behind SSH:

  1. Create SSH tunnel first:
bash
ssh -L 3307:localhost:3306 user@remote-server
  1. Configure DevDb to use tunnel:
json
{
  "type": "mysql",
  "host": "127.0.0.1",
  "port": "3307",
  "username": "root",
  "password": "secret",
  "database": "remote_db"
}

VPN Connection

For databases on VPN:

  1. Connect to VPN first
  2. Use internal host in config:
json
{
  "type": "postgres",
  "host": "db.internal.company.com",
  "port": "5432",
  "username": "developer",
  "password": "secret",
  "database": "staging"
}

Troubleshooting

Configuration Not Loaded

If .devdbrc isn't detected:

  1. Check file location - Must be in workspace root
  2. Verify JSON syntax - Use VS Code's JSON validator
  3. Reload window - Cmd+Shift+P → "Reload Window"
  4. Check DevDb output panel for errors

Connection Fails

If connection doesn't work:

  1. Test credentials manually (e.g., mysql -h host -u user -p)
  2. Verify database is running
  3. Check firewall rules
  4. Review connection options

Environment Variables Not Resolved

If ${env:VAR} doesn't work:

  1. Verify variable is set: echo $VAR (Unix) or echo %VAR% (Windows)
  2. Restart VS Code after setting env vars
  3. Use .env file and a dotenv extension
  4. Check variable name spelling

Validation Errors

If you see validation errors:

  1. Read error message - It indicates what's wrong
  2. Check required fields for the database type
  3. Verify field types (strings, numbers, etc.)
  4. Use snippets for correct structure

Advanced Configuration

Connection Pooling

Configure connection pool options:

json
{
  "type": "mysql",
  "host": "127.0.0.1",
  "username": "root",
  "password": "secret",
  "database": "myapp",
  "options": {
    "connectionLimit": 10,
    "queueLimit": 0,
    "waitForConnections": true
  }
}

SSL Connections

For secure connections:

PostgreSQL:

json
{
  "type": "postgres",
  "host": "secure-db.example.com",
  "username": "user",
  "password": "secret",
  "database": "myapp",
  "options": {
    "ssl": {
      "rejectUnauthorized": true,
      "ca": "/path/to/ca-cert.pem"
    }
  }
}

MySQL:

json
{
  "type": "mysql",
  "host": "secure-db.example.com",
  "username": "user",
  "password": "secret",
  "database": "myapp",
  "options": {
    "ssl": {
      "ca": "/path/to/ca-cert.pem"
    }
  }
}

Read-Only Connections

For safe production inspection:

json
{
  "name": "Production (Read-Only)",
  "type": "mysql",
  "host": "prod-db.example.com",
  "username": "readonly_user",
  "password": "secret",
  "database": "production",
  "options": {
    "readOnly": true
  }
}

Configuration Schema

Full field reference:

Common Fields (All Types)

FieldTypeRequiredDescription
namestringNoConnection display name
typestringYesDatabase type
optionsobjectNoDatabase-specific options

MySQL/MariaDB/PostgreSQL/MSSQL

FieldTypeRequiredDescription
hoststringYesDatabase host
portstring/numberYesDatabase port
usernamestringYesDatabase user
passwordstringYesUser password
databasestringYesDatabase name

SQLite

FieldTypeRequiredDescription
pathstringYesPath to database file

Next Steps

DevDb Pro - Zero-config database management for VS Code