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:

  1. Reads the connection details from the secure secrets store.
  2. Injects them as environment variables into your application's pods.
  3. Keeps the injected values in sync if the credentials are rotated.

Link the database in SVIEW

  1. Open your application Component in SVIEW.
  2. In the configuration, add a dependency block 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
  1. Click Save. The platform applies the change and your pods restart with
    the values available as DB_USERNAME, DB_PASSWORD, and DB_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

ErrorLikely cause
Connection refusedThe database is not running, or DB_HOST is wrong. Check the database Component status in SVIEW.
Authentication faileddependency.db.user does not match a user that exists on the database.
Too many connectionsThe application is exhausting the instance connection limit. Consider a pooler.
Environment variables missingThe 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


Did this page help you?