AI Coding Prompts
Pre-built prompts you can copy directly into an AI coding assistant to scaffold a working DB9 integration. Each prompt includes the DB9 connection pattern, framework best practices, and DB9-specific features.
Compatible with: Claude Code, Cursor, GitHub Copilot, ChatGPT, and any LLM that generates code.
How to use
Section titled “How to use”- Pick the prompt that matches your tech stack below.
- Click the copy button on the code block.
- Paste into your AI assistant.
- Replace
YOUR_DATABASE_URLwith your actual connection string.
JavaScript / TypeScript
Section titled “JavaScript / TypeScript”Next.js + Prisma
Section titled “Next.js + Prisma”Build a Next.js 14+ App Router application with Prisma ORM connected to a DB9 database.
DB9 connection details:- Connection string format: postgresql://<tenant_id>.admin@pg.db9.io:5433/postgres?sslmode=require- Store the connection string in .env.local as DATABASE_URL- DB9 is PostgreSQL-compatible on port 5433 — no custom adapter needed
Requirements:1. Initialize Prisma with the PostgreSQL provider2. Create a schema with at least two related models (e.g. User and Post)3. Set up a singleton PrismaClient in lib/prisma.ts to avoid multiple instances in dev4. Create Server Components that fetch data with Prisma5. Create a Route Handler (app/api/) for mutations6. Create a Server Action for form submissions7. Add proper error handling and TypeScript types
Prisma setup commands: npm install prisma @prisma/client npx prisma init npx prisma db push (for quick schema sync) npx prisma generate
DB9 features to consider:- Use db9 branch create for safe schema experiments before pushing to main- DB9 supports JSONB columns for flexible data- Vector search is available via pgvector for AI/RAG features- Anonymous databases can be created instantly for prototyping: db9 create --name myapp
Reference docs: https://db9.ai/docs/guides/nextjs/ and https://db9.ai/docs/guides/prisma/Next.js + Drizzle
Section titled “Next.js + Drizzle”Build a Next.js 14+ App Router application with Drizzle ORM connected to a DB9 database.
DB9 connection details:- Connection string format: postgresql://<tenant_id>.admin@pg.db9.io:5433/postgres?sslmode=require- Store the connection string in .env.local as DATABASE_URL- DB9 is PostgreSQL-compatible on port 5433 — no custom adapter needed
Requirements:1. Install drizzle-orm and drizzle-kit with the postgres-js driver2. Define a schema in src/db/schema.ts using drizzle's pgTable3. Set up the database client in src/db/index.ts4. Configure drizzle.config.ts pointing to DB95. Create Server Components that query with Drizzle6. Create Route Handlers for mutations7. Use Drizzle's type-safe query builder — avoid raw SQL8. Add proper connection pooling with postgres-js
Install commands: npm install drizzle-orm postgres npm install -D drizzle-kit
Push schema: npx drizzle-kit push
DB9 features to consider:- Use db9 branch create for safe schema migrations before pushing to main- DB9 supports JSONB columns — use Drizzle's jsonb() type- Vector search is available via pgvector for AI/RAG features- Anonymous databases require no signup: db9 create --name myapp
Reference docs: https://db9.ai/docs/guides/nextjs/ and https://db9.ai/docs/guides/drizzle/Express + Knex.js
Section titled “Express + Knex.js”Build an Express.js REST API with Knex.js query builder connected to a DB9 database.
DB9 connection details:- Connection string format: postgresql://<tenant_id>.admin@pg.db9.io:5433/postgres?sslmode=require- Store the connection string in a .env file as DATABASE_URL- DB9 is PostgreSQL-compatible on port 5433 — use the pg driver
Requirements:1. Set up Express with proper middleware (cors, json parsing, error handling)2. Configure Knex with the pg driver pointing to DB93. Create a migration for at least two related tables4. Build CRUD endpoints for the primary resource5. Use Knex transactions for multi-step operations6. Add request validation7. Structure the project: routes/, controllers/, db/ directories
Install commands: npm install express knex pg dotenv npx knex init npx knex migrate:make create_tables npx knex migrate:latest
Knex config for DB9: client: 'pg' connection: process.env.DATABASE_URL pool: { min: 2, max: 10 } ssl: { rejectUnauthorized: false }
DB9 features to consider:- Use db9 branch create to test migrations safely before applying to main- pg_cron is available for scheduled background jobs via SQL- HTTP from SQL: call external APIs directly from DB9 with http_get()/http_post()- Anonymous databases require no signup: db9 create --name myapp
Reference docs: https://db9.ai/docs/guides/knex/ and https://db9.ai/docs/connect/SvelteKit + Drizzle
Section titled “SvelteKit + Drizzle”Build a SvelteKit application with Drizzle ORM connected to a DB9 database.
DB9 connection details:- Connection string format: postgresql://<tenant_id>.admin@pg.db9.io:5433/postgres?sslmode=require- Store the connection string in a .env file as DATABASE_URL- DB9 is PostgreSQL-compatible on port 5433 — no custom adapter needed
Requirements:1. Create a SvelteKit project with TypeScript2. Install drizzle-orm with the postgres-js driver3. Define schema in src/lib/server/db/schema.ts using pgTable4. Set up the db client in src/lib/server/db/index.ts (server-only module)5. Use SvelteKit load functions (+page.server.ts) for data fetching6. Create form actions for mutations7. Use Drizzle's type-safe query builder throughout8. Ensure database code only runs server-side
Install commands: npm install drizzle-orm postgres npm install -D drizzle-kit npx drizzle-kit push
DB9 features to consider:- Use db9 branch create for safe schema experiments- DB9 supports JSONB columns — use Drizzle's jsonb() type- Vector search via pgvector for AI-powered features- Anonymous databases require no signup: db9 create --name myapp
Reference docs: https://db9.ai/docs/guides/drizzle/ and https://db9.ai/docs/connect/Python
Section titled “Python”Python + SQLAlchemy
Section titled “Python + SQLAlchemy”Build a Python application with SQLAlchemy 2.0 connected to a DB9 database.
DB9 connection details:- Connection string format: postgresql://<tenant_id>.admin@pg.db9.io:5433/postgres?sslmode=require- IMPORTANT: SQLAlchemy requires the prefix postgresql+psycopg:// (not postgresql://) Convert the DB9 connection string by replacing "postgresql://" with "postgresql+psycopg://"- Store the connection string in a .env file as DATABASE_URL
Requirements:1. Use SQLAlchemy 2.0 API with mapped_column and type-annotated models2. Use psycopg3 (psycopg[binary]) as the driver — not psycopg23. Create an engine with pool_pre_ping=True4. Define at least two related models with relationships5. Use sessionmaker and context managers for transactions6. Implement CRUD operations using the 2.0 query API7. Add Alembic for migrations
Install commands: pip install "sqlalchemy>=2.0.0" "psycopg[binary]>=3.1.0" python-dotenv pip install alembic # for migrations
DB9 features to consider:- Use db9 branch create for safe schema experiments before applying migrations- Vector search: pip install pgvector, then use the Vector type for embedding columns- DB9 supports JSONB — use sqlalchemy.dialects.postgresql.JSONB- Anonymous databases require no signup: db9 create --name myapp
Reference docs: https://db9.ai/docs/guides/python-sqlalchemy/Django
Section titled “Django”Build a Django application connected to a DB9 database.
DB9 connection details:- Host: pg.db9.io- Port: 5433- Database name: postgres- User: <tenant_id>.admin- DB9 is PostgreSQL-compatible — use Django's built-in postgresql backend
Requirements:1. Create a Django project with at least one app2. Configure DATABASES in settings.py for DB93. Define models with at least two related tables4. Create and apply migrations5. Set up Django REST Framework for an API (or use views)6. Add admin site configuration7. Use environment variables for credentials (django-environ or python-dotenv)
Django DATABASES config for DB9: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'postgres', 'USER': '<tenant_id>.admin', 'PASSWORD': '<your_password>', 'HOST': 'pg.db9.io', 'PORT': '5433', 'OPTIONS': {'sslmode': 'require'}, } }
Install commands: pip install django psycopg[binary] django-environ django-admin startproject myproject python manage.py startapp myapp python manage.py migrate
DB9 features to consider:- Use db9 branch create to test migrations on a branch before applying to main- Django's JSONField works with DB9's JSONB support- Vector search: install pgvector and django-pgvector for AI/RAG features- Anonymous databases require no signup: db9 create --name myapp
Reference docs: https://db9.ai/docs/connect/Build a Flask REST API with SQLAlchemy connected to a DB9 database.
DB9 connection details:- Connection string format: postgresql://<tenant_id>.admin@pg.db9.io:5433/postgres?sslmode=require- IMPORTANT: For SQLAlchemy, replace "postgresql://" with "postgresql+psycopg://"- Store the connection string in a .env file as DATABASE_URL
Requirements:1. Set up Flask with Flask-SQLAlchemy for ORM integration2. Use SQLAlchemy 2.0 style models with mapped_column3. Use psycopg3 (psycopg[binary]) as the driver4. Define at least two related models5. Create RESTful CRUD endpoints using Flask blueprints6. Use Flask-Migrate (Alembic) for database migrations7. Add proper error handling and JSON responses8. Structure the project with an application factory pattern
Install commands: pip install flask flask-sqlalchemy "psycopg[binary]>=3.1.0" flask-migrate python-dotenv
Flask-SQLAlchemy config for DB9: SQLALCHEMY_DATABASE_URI must use the postgresql+psycopg:// prefix SQLALCHEMY_ENGINE_OPTIONS = {"pool_pre_ping": True}
DB9 features to consider:- Use db9 branch create for safe schema experiments before migrating- Vector search: pip install pgvector for AI/RAG features- DB9 supports JSONB for flexible document storage- Anonymous databases require no signup: db9 create --name myapp
Reference docs: https://db9.ai/docs/guides/python-sqlalchemy/ and https://db9.ai/docs/connect/Go + GORM
Section titled “Go + GORM”Build a Go REST API with GORM connected to a DB9 database.
DB9 connection details:- Connection string (DSN): postgresql://<tenant_id>.admin@pg.db9.io:5433/postgres?sslmode=require- GORM uses the pgx v5 driver via gorm.io/driver/postgres- Store the DSN in an environment variable DATABASE_URL
Requirements:1. Set up a Go project with GORM and the postgres driver2. Define struct models with gorm tags for at least two related tables3. Use AutoMigrate for schema setup4. Build a REST API using net/http or chi/gin router5. Implement CRUD operations with proper error handling6. Use GORM transactions for multi-step operations7. Add connection pooling configuration via database/sql
Install commands: go mod init myapp go get gorm.io/gorm gorm.io/driver/postgres
GORM connection setup: dsn := os.Getenv("DATABASE_URL") db, err := gorm.Open(postgres.New(postgres.Config{DSN: dsn}), &gorm.Config{}) sqlDB, _ := db.DB() sqlDB.SetMaxOpenConns(25) sqlDB.SetMaxIdleConns(5)
DB9 features to consider:- Use db9 branch create for safe schema experiments before AutoMigrate on main- Vector search: use pgvector-go for embedding columns- DB9 supports JSONB — use datatypes.JSON from gorm.io/datatypes- Anonymous databases require no signup: db9 create --name myapp
Reference docs: https://db9.ai/docs/guides/gorm/Rust + SQLx
Section titled “Rust + SQLx”Build a Rust web service with SQLx connected to a DB9 database.
DB9 connection details:- Connection string format: postgresql://<tenant_id>.admin@pg.db9.io:5433/postgres?sslmode=require- Store the connection string in a .env file as DATABASE_URL- SQLx connects via the PostgreSQL protocol — DB9 is fully compatible
Requirements:1. Set up a Rust project with SQLx (postgres feature + runtime-tokio + tls-rustls)2. Use sqlx::PgPool for connection pooling3. Define models as Rust structs deriving FromRow4. Use compile-time checked queries with sqlx::query_as! where possible5. Build a REST API using Axum or Actix-web6. Implement CRUD endpoints with proper error handling7. Use SQLx migrations for schema management
Cargo.toml dependencies: sqlx = { version = "0.8", features = ["runtime-tokio", "tls-rustls", "postgres", "macros"] } tokio = { version = "1", features = ["full"] } axum = "0.7" # or actix-web dotenvy = "0.15" serde = { version = "1", features = ["derive"] }
SQLx commands: sqlx database create (not needed — DB9 database already exists) sqlx migrate add create_tables sqlx migrate run
DB9 features to consider:- Use db9 branch create to test migrations on a branch before applying to main- Vector search: use pgvector with SQLx for embedding storage and similarity search- DB9 supports JSONB — use sqlx::types::Json<T>- Anonymous databases require no signup: db9 create --name myapp
Reference docs: https://db9.ai/docs/connect/Build a Ruby on Rails application connected to a DB9 database.
DB9 connection details:- Host: pg.db9.io- Port: 5433- Database name: postgres- User: <tenant_id>.admin- DB9 is PostgreSQL-compatible — use the standard pg gem
Requirements:1. Create a new Rails app with the PostgreSQL adapter2. Configure config/database.yml for DB93. Generate at least two related models with a migration4. Set up Active Record associations5. Create a RESTful controller with CRUD actions6. Add model validations7. Use Rails credentials or environment variables for the password
database.yml config for DB9: default: &default adapter: postgresql host: pg.db9.io port: 5433 database: postgres username: <tenant_id>.admin password: <%= ENV["DB9_PASSWORD"] %> sslmode: require
Install commands: rails new myapp --database=postgresql cd myapp rails generate model User name:string email:string rails generate model Post title:string body:text user:references rails db:migrate
DB9 features to consider:- Use db9 branch create to test migrations on a branch before applying to production- Rails jsonb columns work natively with DB9- Vector search: use the neighbor gem with pgvector for AI/RAG features- Anonymous databases require no signup: db9 create --name myapp
Reference docs: https://db9.ai/docs/connect/What’s included in every prompt
Section titled “What’s included in every prompt”Each prompt above follows a consistent structure:
| Section | Purpose |
|---|---|
| Connection details | DB9 host, port (5433), connection string format, environment variable naming |
| Framework setup | Install commands, project structure, configuration |
| Code requirements | Models, CRUD, transactions, error handling |
| DB9 features | Branching, anonymous databases, vector search, JSONB, and other capabilities |
| Reference links | Pointers to the relevant DB9 docs for the AI to consult |
Next steps
Section titled “Next steps”- Install the DB9 CLI to create databases: Quick Start
- Set up agent integration for deeper AI workflows: Agent Workflows
- Give Claude Code the DB9 skill for native database access: Claude Code
- Connect your app with detailed framework guides: Connection Strings