Databases
Connecting PostgreSQL and Supabase to a project, browsing the schema, running SQL safely, and using the connection from generated code.
On this page
Codexa does not host databases. You connect an existing PostgreSQL server or a Supabase project, and Codexa gives you a schema browser and a SQL runner inside the project, plus the connection string as an environment variable for your code.
Add a connection
- Open the project's Database panel and choose Add connection.
- Pick PostgreSQL or Supabase. For Supabase, use the connection string from the project's database settings (the pooled "transaction" URL works for serverless-style apps).
- Paste the connection string. It is encrypted before storage and never returned to the browser again.
- Test performs a
SELECT 1and reports success or the driver's error message.
Connections are workspace resources; admins manage them under Integrations and any project in the workspace can use them.
Schema browser
The panel lists schemas, tables, columns with types and nullability, primary keys and indexes, read live from information_schema. It is read-only.
SQL runner
Type a statement and run it. Results show rows, fields and the row count, capped at 500 rows per query.
The runner uses the credentials of the connection, so whatever that role can do, the runner can do. Use a least-privilege role for day-to-day work.
Using the database from your code
Codexa injects nothing automatically. Add an environment variable (for example DATABASE_URL) in the project's environment variables and read it from your code. For a Node + Express template:
import pg from "pg";
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
app.get("/api/orders", async (_req, res) => {
const { rows } = await pool.query("select id, total from orders order by id desc limit 50");
res.json(rows);
});
For a Vite + React single-page app there is no server, so the browser must not hold database credentials. Either add a Node + Express project as the API, or use Supabase's row-level security with the public anon key.
Migrations
Codexa does not run migrations for you. Keep migration files in the project (the Node template ships with a migrations/ folder and an npm script) and run them with Run command → build/test or from your own machine.
Asking the agent
The agent can read your connection names and the schema browser output you paste, but it has no tool to query the database. Paste the relevant CREATE TABLE statements into the prompt when you ask for code that touches them.