Documentation Index Fetch the complete documentation index at: https://docs.case.dev/llms.txt
Use this file to discover all available pages before exploring further.
Get PostgreSQL connection strings for your database projects. Supports direct connections, connection pooling, and branch-specific connections.
Get connection string
cURL
CLI
Typescript
Python
C#
Java
PHP
Go
curl https://api.case.dev/database/v1/projects/proj_abc123/connection \
-H "Authorization: Bearer $CASEDEV_API_KEY "
Parameters
Parameter Type Required Description branchstring No Branch name (defaults to main) pooledboolean No Use pooled connection via PgBouncer
Response
Field Type Description connectionUristring PostgreSQL connection string (includes credentials) branchstring Branch name for this connection pooledboolean Whether this is a pooled connection
Direct vs pooled connections
Direct connections
Best for:
Long-running processes
Migration scripts
Administrative tasks
Applications with few connections
cURL
CLI
Typescript
Python
C#
Java
PHP
Go
curl "https://api.case.dev/database/v1/projects/ $PROJECT_ID /connection" \
-H "Authorization: Bearer $CASEDEV_API_KEY "
Pooled connections (PgBouncer)
Best for:
Serverless functions
High-concurrency applications
Short-lived connections
cURL
CLI
Typescript
Python
C#
Java
PHP
Go
curl "https://api.case.dev/database/v1/projects/ $PROJECT_ID /connection?pooled=true" \
-H "Authorization: Bearer $CASEDEV_API_KEY "
Pooled connections go through PgBouncer, which maintains a pool of database connections. This is essential for serverless environments where you might have many short-lived function invocations.
Branch-specific connections
Get a connection string for a specific branch:
cURL
CLI
Typescript
Python
C#
Java
PHP
Go
# Get staging branch connection
curl "https://api.case.dev/database/v1/projects/ $PROJECT_ID /connection?branch=staging" \
-H "Authorization: Bearer $CASEDEV_API_KEY "
# Get feature branch connection (pooled)
curl "https://api.case.dev/database/v1/projects/ $PROJECT_ID /connection?branch=feature-auth&pooled=true" \
-H "Authorization: Bearer $CASEDEV_API_KEY "
Integration examples
Drizzle ORM
import { drizzle } from 'drizzle-orm/postgres-js' ;
import postgres from 'postgres' ;
const conn = await client . database . v1 . projects . getConnection ( projectId );
const sql = postgres ( conn . connectionUri );
const db = drizzle ( sql );
// Query
const users = await db . select (). from ( usersTable );
Prisma
// Get connection string
const conn = await client . database . v1 . projects . getConnection ( projectId , {
pooled : true // Recommended for Prisma
});
// Set in .env or environment
process . env . DATABASE_URL = conn . connectionUri ;
// prisma/schema.prisma
// datasource db {
// provider = "postgresql"
// url = env("DATABASE_URL")
// }
Raw pg (node-postgres)
import { Pool } from 'pg' ;
const conn = await client . database . v1 . projects . getConnection ( projectId , {
pooled : true
});
const pool = new Pool ({
connectionString : conn . connectionUri
});
const result = await pool . query ( 'SELECT * FROM users WHERE id = $1' , [ userId ]);
Python psycopg2
import psycopg2
conn = client.database.v1.projects. get_connection (project_id)
db = psycopg2. connect (conn.connection_uri)
cursor = db. cursor ()
cursor. execute ( "SELECT * FROM users WHERE id = %s " , (user_id,))
Python SQLAlchemy
from sqlalchemy import create_engine
conn = client.database.v1.projects. get_connection (project_id, pooled = True )
engine = create_engine (conn.connection_uri)
with engine. connect () as connection:
result = connection. execute ( "SELECT * FROM users" )
Security
Connection strings include database credentials. Never expose them in client-side code, logs, or version control.
Best practices:
Store connection strings in environment variables
Use secret management services (AWS Secrets Manager, Vault)
Rotate credentials periodically
Use pooled connections for serverless to limit open connections
// Good: Environment variable
const databaseUrl = process . env . DATABASE_URL ;
// Bad: Hardcoded
const databaseUrl = "postgresql://user:password@host/db" ; // Never do this
postgresql://[user]:[password]@[host]/[database]?sslmode=require
Component Description userDatabase username passwordDatabase password hostNeon endpoint hostname databaseDatabase name (default: neondb) sslmodeSSL mode (always require)
Example:
postgresql://neondb_owner:abc123xyz@ep-quiet-meadow-123456.us-east-1.aws.neon.tech/neondb?sslmode=require