Databases
Kamui Platform lets you easily create and manage PostgreSQL databases.
Supported Databases
Currently, only PostgreSQL is supported.
Creating a Database
- In the project detail screen, click "New Database"
- Enter the following information:
| Field | Description | Example |
|---|---|---|
| Database Name | Identifier name | main-db |
| Spec | Resource size | Nano / Small / Medium / Large |
- Click "Create"
Database creation may take a few minutes. It's available once the status shows "running".
Connecting from Applications
Automatic Environment Variable Injection
When you select a database while creating an application, the following environment variables are automatically set:
| Environment Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection URL (complete connection string) |
DATABASE_HOST |
Hostname |
DATABASE_PORT |
Port number (usually 5432) |
DATABASE_NAME |
Database name |
DATABASE_USER |
Username |
DATABASE_PASSWORD |
Password |
Connection Examples
Node.js (pg library)
const { Pool } = require('pg');
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
});
const result = await pool.query('SELECT NOW()');
console.log(result.rows[0]);
Go
import (
"database/sql"
"os"
_ "github.com/lib/pq"
)
db, err := sql.Open("postgres", os.Getenv("DATABASE_URL"))
if err != nil {
log.Fatal(err)
}
Python
import os
import psycopg2
conn = psycopg2.connect(os.environ['DATABASE_URL'])
cursor = conn.cursor()
cursor.execute('SELECT NOW()')
print(cursor.fetchone())
Viewing Connection Information
- Open the database detail screen
- Check the "Connection Info" section for:
- Connection URL
- Host
- Port
- Username
- Password (click the show button)
Security Note: Keep your password secure.
Database Status
| Status | Description |
|---|---|
| creating | Being created |
| running | Running normally |
| stopped | Stopped |
| error | Error occurred |
Editing a Database
- Click the "Settings" tab in the database detail screen
- Editable fields:
- Spec (resource size)
- Click "Save"
Note: Changing the spec will restart the database.
Deleting a Database
- Click the "Settings" tab in the database detail screen
- Click "Delete Database"
- Enter the database name in the confirmation dialog
- Click "Delete"
⚠️ Warning: Deleting a database will permanently delete all data. This action cannot be undone. We recommend backing up before deletion.
Best Practices
Use Connection Pooling
Don't keep database connections open. Use connection pools instead.
// ❌ Creating connection per request
const client = new Client({ connectionString: process.env.DATABASE_URL });
await client.connect();
// ✅ Using connection pool
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const result = await pool.query('SELECT * FROM users');
Set Connection Timeouts
Idle connections may be timed out. Implement retry logic.
Don't Use Production Data in Development
For security, don't use production database credentials in development environments.