Database Management
Create, list, and manage local PostgreSQL databases.
Creating Databases
Basic Creation
postbase db create myappOutput:
✓ Database 'myapp' created
Connection:
postgresql://postgres:postgres@localhost:5432/myappWith Template
Create from an existing database:
postbase db create myapp_test --template myappListing Databases
postbase db listOutput:
Databases:
myapp
Size: 12.5 MB
Tables: 8
Created: 2026-01-25 10:30:00
demo
Size: 3.2 MB
Tables: 3
Created: 2026-01-24 15:45:00JSON Output
postbase db list --json{
"databases": [
{
"name": "myapp",
"size": 13107200,
"tableCount": 8,
"createdAt": "2026-01-25T10:30:00Z"
}
]
}Database Details
postbase db info myappOutput:
Database: myapp
Size: 12.5 MB
Tables: 8
Views: 2
Functions: 5
Indexes: 12
Schemas:
- public (8 tables)
- auth (2 tables)
Extensions:
- uuid-ossp
- pgcryptoDeleting Databases
With Confirmation
postbase db drop myappOutput:
⚠ This will permanently delete the database 'myapp'
and all its data. This cannot be undone.
Are you sure? (y/N): y
✓ Database 'myapp' droppedForce Delete
postbase db drop myapp --forceConnection Details
Get Connection String
postbase connect myappOutput:
Database: myapp
Connection Details:
Host: localhost
Port: 5432
Database: myapp
User: postgres
Password: postgres
Connection String:
postgresql://postgres:postgres@localhost:5432/myapp
psql Command:
psql "postgresql://postgres:postgres@localhost:5432/myapp"Copy to Clipboard
postbase connect myapp --copyJSON Output
postbase connect myapp --json{
"host": "localhost",
"port": 5432,
"database": "myapp",
"user": "postgres",
"password": "postgres",
"connectionString": "postgresql://postgres:postgres@localhost:5432/myapp"
}Using with Applications
Environment Variables
# .env
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/myapp"Node.js (pg)
import pg from 'pg'
const pool = new pg.Pool({
connectionString: 'postgresql://postgres:postgres@localhost:5432/myapp',
})
const result = await pool.query('SELECT * FROM users')Postbase SDK
import { createClient } from '@postbase/sdk'
const db = createClient({
connectionString: 'postgresql://postgres:postgres@localhost:5432/myapp',
})
const users = await db.from('users').execute()Prisma
// schema.prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}Drizzle
import { drizzle } from 'drizzle-orm/node-postgres'
import { Pool } from 'pg'
const pool = new Pool({
connectionString: 'postgresql://postgres:postgres@localhost:5432/myapp',
})
const db = drizzle(pool)Direct psql Access
# Connect with psql
psql "postgresql://postgres:postgres@localhost:5432/myapp"
# Or using environment variable
export PGPASSWORD=postgres
psql -h localhost -U postgres -d myappDatabase Operations via API
All operations are available via the daemon API:
List Databases
curl http://localhost:9432/databasesCreate Database
curl -X POST http://localhost:9432/databases \
-H "Content-Type: application/json" \
-d '{"name": "newdb"}'Get Database Details
curl http://localhost:9432/databases/myappDelete Database
curl -X DELETE http://localhost:9432/databases/myappBest Practices
Naming Conventions
- Use lowercase names:
myappnotMyApp - Use underscores for multi-word:
my_appnotmy-app - Avoid reserved words:
user,order,table
Development Workflow
# Create development database
postbase db create myapp_dev
# Create test database
postbase db create myapp_test --template myapp_dev
# Run tests
npm test
# Drop test database
postbase db drop myapp_test --forceDatabase per Environment
# Local development
postbase db create myapp_dev
# Local testing
postbase db create myapp_test
# CI environment (use cloud)
postbase cloud provision ci --ephemeral