Guide: Provision a PostgreSQL Database
This guide walks you through provisioning a managed PostgreSQL database on Cognitera Intelligence.
Prerequisites
- A registered account (Getting Started)
- A valid JWT token
Step 1: Provision the Database
curl -X POST https://intelligence.cognitera.ai/api/databases \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
You'll receive connection details:
{
"id": "db-uuid",
"databaseName": "client_550e8400_a1b2c3d4",
"host": "intelligence.cognitera.ai",
"port": 5432,
"username": "user_a1b2c3d4e5f6",
"password": "generated-password",
"connectionString": "postgresql://user_a1b2c3d4e5f6:generated-password@intelligence.cognitera.ai:5432/client_550e8400_a1b2c3d4"
}
Step 2: Connect with Your Application
Use the connection string with any PostgreSQL client:
Node.js (pg)
const { Pool } = require('pg');
const pool = new Pool({
connectionString: 'postgresql://user_a1b2c3d4e5f6:generated-password@intelligence.cognitera.ai:5432/client_550e8400_a1b2c3d4'
});
const result = await pool.query('SELECT NOW()');
console.log(result.rows[0]);
Python (psycopg2)
import psycopg2
conn = psycopg2.connect(
"postgresql://user_a1b2c3d4e5f6:generated-password@intelligence.cognitera.ai:5432/client_550e8400_a1b2c3d4"
)
cursor = conn.cursor()
cursor.execute("SELECT NOW()")
print(cursor.fetchone())
Step 3: Monitor Storage
Check your database's storage usage:
curl https://intelligence.cognitera.ai/api/databases/DB_ID \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Step 4: Clean Up
When you no longer need the database:
curl -X DELETE https://intelligence.cognitera.ai/api/databases/DB_ID \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
danger
Destroying a database is permanent. Back up your data first.