DigitalOcean Managed Database provisioning and connection patterns
View on GitHubFebruary 1, 2026
Select agents to install to:
npx add-skill https://github.com/vanman2024/ai-dev-marketplace/blob/main/plugins/digitalocean/skills/managed-databases/SKILL.md -a claude-code --skill managed-databasesInstallation paths:
.claude/skills/managed-databases/# Managed Databases Skill
## PostgreSQL
### Provisioning
```bash
# Create production cluster
doctl databases create prod-pg \
--engine pg \
--version 16 \
--region nyc1 \
--size db-s-2vcpu-4gb \
--num-nodes 2 \
--private-network-uuid <vpc-id>
```
### Connection Patterns
**Node.js (pg):**
```typescript
import { Pool } from 'pg';
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: true,
ca: process.env.DATABASE_CA_CERT,
},
max: 20,
idleTimeoutMillis: 30000,
connectionTimeoutMillis: 2000,
});
// Query
const { rows } = await pool.query('SELECT * FROM users WHERE id = $1', [id]);
// Transaction
const client = await pool.connect();
try {
await client.query('BEGIN');
await client.query('INSERT INTO users(name) VALUES($1)', ['John']);
await client.query('COMMIT');
} catch (e) {
await client.query('ROLLBACK');
throw e;
} finally {
client.release();
}
```
**Python (psycopg2):**
```python
import psycopg2
from psycopg2.extras import RealDictCursor
conn = psycopg2.connect(
os.environ['DATABASE_URL'],
sslmode='require',
sslrootcert='ca-certificate.crt',
cursor_factory=RealDictCursor
)
with conn.cursor() as cur:
cur.execute("SELECT * FROM users WHERE id = %s", (user_id,))
user = cur.fetchone()
```
**Prisma:**
```prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
```
**Drizzle:**
```typescript
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: { rejectUnauthorized: true },
});
export const db = drizzle(pool);
```
### Connection Pooling
```bash
# Create connection pool
doctl databases pool create <cluster-id> app-pool \
--db myapp_production \
--user app_user \
--mode transaction \
--size 25
```
## Redis/Valkey
### Provisioning
```bash
doctl databases create prod-cache \
--engine valkey \
--version 7 \