RimbraDocs

Connect a database to a project

Attach a database and your app reads it from an environment variable.

Connect

  1. 1Open the project and choose Connect.
  2. 2Pick the database. The variable name defaults to DATABASE_URL; change it if your app expects another.
  3. 3Choose Connect, then Redeploy so the app receives the variable.

Variables you get

EngineVariables
PostgreSQLDATABASE_URL, PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE
MySQLDATABASE_URL, MYSQL_URL, MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE
RedisREDIS_URL, REDIS_HOST, REDIS_PORT, REDIS_PASSWORD

Use it in your app

examples
// Prisma (schema.prisma)
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

// node-postgres
import pg from "pg"
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })

# Python
import os, psycopg
conn = psycopg.connect(os.environ["DATABASE_URL"])

Disconnect

Disconnecting removes the variable from the project on its next deploy. The database and its data stay as they are.