Attach to Your Application
You have a database provisioned in SVIEW and you want your application to use
it. Linking the two Components tells the platform to inject the connection
details into your pods as environment variables.
Before you start
- The database Component is provisioned and showing a healthy status in SVIEW.
- You know the database name exactly as SVIEW displays it, and the namespace it
belongs to. - You know which database user your application should connect as. This user is
created when the database is provisioned — if you are not sure which one to
use, raise a request. - You can edit the application Component's configuration in SVIEW.
Because the platform injects the credentials at deploy time, you do not put a
username, password, or endpoint in your repository. Rotating a password does not
require a code change — the injected values are kept in sync.
How credential injection works
When you link a database Component to an application Component, the platform:
- Reads the connection details from the secure secrets store.
- Injects them as environment variables into your application's pods.
- Keeps the injected values in sync if the credentials are rotated.
Link the database in SVIEW
- Open your application Component in SVIEW.
- In the configuration, add a
dependencyblock that references your database
Component:
dependency:
db:
type: rds-postgres # or rds-mysql
instance: <db-name> # the name shown in SVIEW
namespace: <namespace>
user: app_user
keys:
- secretKey: username
envKey: DB_USERNAME
- secretKey: password
envKey: DB_PASSWORD
- secretKey: endpoint
envKey: DB_HOST- Click Save. The platform applies the change and your pods restart with
the values available asDB_USERNAME,DB_PASSWORD, andDB_HOST.
Verify it worked
Confirm the application Component returns to a healthy status in SVIEW after the
restart, and that your application log shows a successful database connection
rather than a startup failure. If the variables are missing inside the container,
the dependency block did not apply — see the table below.
Use the credentials in your application
Python:
import os, psycopg2
conn = psycopg2.connect(
host=os.environ["DB_HOST"],
user=os.environ["DB_USERNAME"],
password=os.environ["DB_PASSWORD"],
dbname="your_schema"
)Node.js:
const { Pool } = require('pg');
const pool = new Pool({
host: process.env.DB_HOST,
user: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: 'your_schema',
});Connection pooling
For production workloads running several replicas, consider a connection pooler
such as PgBouncer for PostgreSQL. Each replica holds its own open connections, so
a pooler keeps the total count within the instance's limit. Raise a request if
you would like a pooler deployed.
Common issues
| Error | Likely cause |
|---|---|
Connection refused | The database is not running, or DB_HOST is wrong. Check the database Component status in SVIEW. |
Authentication failed | dependency.db.user does not match a user that exists on the database. |
Too many connections | The application is exhausting the instance connection limit. Consider a pooler. |
| Environment variables missing | The dependency block is misconfigured. Check the Component configuration and save again. |
If the issue persists, raise a request with the application name, the database
name, and the exact error.
Related articles
Updated about 6 hours ago