Zero Config
Automatically add database connections found in .env and web.config files, or supported .db files.
DBCode looks for connection information either as a connection string or defined configuration in known formats in the following locations within the root folder:
- Env files (*.env): Files that contain environment variables with connection strings or individual database configuration keys.
- Web Config files (web.config): Configuration files used by web applications that may include connection settings.
- DDev (.ddev/config.yaml): YAML files used by DDev for configurations, including database connection details.
If connection information is found and successfully parsed from these files, DBCode will automatically add it as a database connection.
DBCode also scans for compatible database files for supported databases in the root directory (currently .db, .duckdb, .sqlite, .sqlite3, etc). If such a file is found, it will be automatically added as a database connection.
Supported .env Patterns
DBCode automatically detects database connections in .env files using two methods:
Connection String URLs
Standard database connection URLs are detected automatically:
DATABASE_URL=postgres://user:pass@localhost:5432/dbnameMYSQL_URL=mysql://root:secret@127.0.0.1:3306/mydbREDIS_URL=redis://localhost:6379Individual Key-Value Pairs
DBCode also detects common framework patterns that use separate environment variables for each connection parameter.
Laravel
DB_CONNECTION=mysqlDB_HOST=127.0.0.1DB_PORT=3306DB_DATABASE=laravelDB_USERNAME=rootDB_PASSWORD=secretDjango
DATABASE_NAME=mydbDATABASE_USER=userDATABASE_PASSWORD=passDATABASE_HOST=localhostDATABASE_PORT=5432DATABASE_ENGINE=django.db.backends.postgresqlSpring Boot
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/mydbSPRING_DATASOURCE_USERNAME=userSPRING_DATASOURCE_PASSWORD=passNode.js / Generic
DB_HOST=localhostDB_PORT=3306DB_DATABASE=myappDB_USERNAME=rootDB_PASSWORD=secretMultiple Connections
You can define multiple database connections in a single .env file using prefixes:
PRIMARY_DB_HOST=localhostPRIMARY_DB_PORT=5432PRIMARY_DB_DATABASE=primary
SECONDARY_DB_HOST=remote.example.comSECONDARY_DB_PORT=3306SECONDARY_DB_DATABASE=secondaryDriver Detection
DBCode automatically determines the database type from:
- Explicit connection type (e.g.,
DB_CONNECTION=mysql) - Database engine (e.g.,
DATABASE_ENGINE=django.db.backends.postgresql) - JDBC URL prefix (e.g.,
jdbc:postgresql://) - Port number (e.g., 5432 for PostgreSQL, 3306 for MySQL)
Discovered Connections
Automatically discovered connections are indicated by a compass icon (🧭), making it easy to identify and manage them.
The DB Explorer can also be filtered to only show connections that have been discovered automatically by using the compass icon (🧭) at the top of the DB Explorer.
Workspace Default Connection
When DBCode discovers connections from your workspace (e.g., from .env files, SQLite databases, or other configuration files), it automatically tracks them as workspace default candidates. This enables teams to share a common workspace configuration without committing credentials.
How It Works
-
Explicit setting takes priority: If you have explicitly set a workspace default connection using the
dbcode.workspaceConnectionsetting (via the “Set as Workspace Default” command), that setting always takes priority over discovered connections. -
Single discovered connection: If no explicit setting exists and only one connection is discovered in your workspace, it automatically becomes the workspace default.
-
Multiple discovered connections: If multiple connections are discovered, DBCode will prompt you to choose which one should be the default when needed.
-
Matching saved connections: If a discovered connection matches an existing saved connection (same driver, host, port), DBCode automatically resolves to the saved connection. This means your team can share
.envfiles while each developer uses their own saved credentials.
Visual Indicators
Connections in the DB Explorer show status indicators:
- ☆ (star): Indicates the workspace default connection
- ● (dot): Indicates a connected connection
- ☆● (star + dot): Indicates the workspace default that is also connected
Sharing Across Teams
This feature solves the problem of sharing workspace default connections across developers:
- Commit your
.code-workspacefile to version control - Each developer maintains their own
.envfile with credentials (not committed) - DBCode discovers the connection from
.envand uses it as the workspace default - If a developer has a matching saved connection, DBCode automatically uses that instead
This approach keeps credentials secure while allowing teams to share which connection should be used for the workspace.
Additional Config Types
We recognize that there are many other types of configuration files and formats used for database connections.
Please let us know if you have specific configuration file types or formats that you need DBCode to support.