PostgreSQL with pgvector for your AI app
Store embeddings next to your data and find the closest ones, in a PostgreSQL with pgvector on from the start.
Ask your agent
Create a PostgreSQL database with pgvector for this app on Rowsafe Cloud and connect it with DATABASE_URL in .env.Your agent picks a size, tells you the price and waits for your yes. Then it creates the server as you and, once it's ready (5 to 10 minutes), puts DATABASE_URL in .env. Through the Claude Code or Codex plugin, you create the login in the dashboard instead and paste it in: the password is made in your browser.
First time? Connect Rowsafe to your agent once.
Or from the terminal
rowsafe cloud create ai-db --extensions vector --wait
rowsafe env --on ai-dbrowsafe cloud create shows the price and asks first. rowsafe env makes the password on your computer, writes DATABASE_URL to .env and adds .env to .gitignore. Rowsafe never sees it. pgvector is on in every new database, so there's no CREATE EXTENSION to run.
Connect your app
CREATE TABLE documents (
id bigserial PRIMARY KEY,
content text NOT NULL,
embedding vector(1536) -- your embedding model's size
);
CREATE INDEX ON documents USING hnsw (embedding vector_cosine_ops);import { Pool } from "pg";
const db = new Pool({ connectionString: process.env.DATABASE_URL });
export async function nearest(embedding: number[]) {
const { rows } = await db.query(
"SELECT id, content FROM documents ORDER BY embedding <=> $1::vector LIMIT 5",
[JSON.stringify(embedding)],
);
return rows;
}<=> is the cosine distance, closest first, in any language. In .env, change sslmode=require to sslmode=verify-full: the server's certificate is then checked too.
Backups and restores
Rowsafe backs up every change, encrypted on the server with a key only you have, so you can restore to any second. Every week it restores a backup to prove it works. Restore a copy, bring back deleted rows or rewind the whole database, in one click. Before a risky change, save a Mark (rowsafe mark), or let your agent save one.
From $0.014 an hour, never more than $10 a month.
Questions
Is this a Supabase alternative?
For the database, yes: PostgreSQL with pgvector, backups and monitoring. Rowsafe has no sign-in, file storage or generated APIs, so those stay in your app.
Can I turn pgvector on later?
Yes, in one database from Databases & users, with no restart. Picked when you create the server, it's on in every new database.
Can I move my data from Supabase, Neon, RDS or Heroku?
Yes, with Move in: it copies your database while your app keeps running (from Heroku, writes pause during the copy). How it works
More guides
- Add PostgreSQL to your Next.js appNext.js, node-postgres
- Managed MySQL for your Laravel appLaravel, MySQL 8.4
- Managed PostgreSQL for your Django appDjango, psycopg
- Managed PostgreSQL for your Rails appRuby on Rails, pg
- PostgreSQL for your Express app, with PrismaNode.js, Express, Prisma
- PostgreSQL for your FastAPI app, with SQLAlchemyFastAPI, SQLAlchemy, psycopg
- A Valkey (Redis) cache for your Next.js appNext.js, node-redis
- Meilisearch for your Laravel app, with ScoutLaravel Scout, Meilisearch
- Managed MariaDB for your WordPress siteWordPress, MariaDB 11.8