# How to add a Postgres database to your app.

URL: https://antideploy.com/blog/how-to-add-a-postgres-database-to-your-app

Ask your coding agent for a database. Antideploy creates Postgres 17 beside your app and sets DATABASE_URL, with no other account to open.

## At a glance

- **Postgres 17**: On Neon, in Singapore
- **DATABASE_URL**: Set in development and production
- **Migrations**: Run before the new version goes live
- **One database for both**: What you tested is what ships

Published 7 October 2026. Facts checked 7 October 2026. 3 min read.

## The short answer

To add a Postgres database to your app, tell your connected coding agent to add one. It creates a Postgres 17 database beside your app, writes the connection details into your `.env` file without printing them, and builds and tests your code against it. `DATABASE_URL` is set in the running app too, so there is nothing to copy. You do not need another account.

> **Say this to your coding agent**
>
> Add a Postgres database to this project and use it for my data.

If your agent is not connected yet, paste this first: Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.

## What your agent does

### 1. It asks for the database before it writes the code

Your agent creates the database first, so your code is written and tested against the real thing. Asking twice returns the same database, so nothing is made twice.

### 2. It writes the connection into your .env

The variables go into your `.env` file through a redirect that never prints the password. The password is never in the chat or the terminal.

### 3. The same database goes live with the app

Development and production use one database. Before the app goes live it is a scratch space. Once it is live, its data is real, so the agent is told not to reset or reseed it without asking.

## How your code connects

Read `DATABASE_URL` from the environment. The `PG*` variables hold the same connection split into host, port, user, password and database name, for tools that read those.

**Node**

```
import pg from "pg";

const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
const { rows } = await pool.query("select * from trees limit 10");

# Python
import os, psycopg

with psycopg.connect(os.environ["DATABASE_URL"]) as conn:
    rows = conn.execute("select * from trees limit 10").fetchall()
```

Prisma, Drizzle, SQLAlchemy and Django read `DATABASE_URL` or a setting built from it. The connection is pooled.

## Migrations

If your project has a migration command, Antideploy runs it after the build and before the new version goes live. It detects Prisma, Drizzle, Alembic and Django. A failed migration fails the deploy, so a version your schema cannot support is never released.

## What it counts against

A database counts toward your plan's allowance however it was created: 1 on Free and Go, 3 on Pro and 5 on Scale, counted per account. A static site never needs one. Databases cost nothing extra.

## Here's where it stops.

A platform that only tells you what it is good at is one you find the edges of in production. These are the ones to know before your first deploy.

### Postgres only

Antideploy creates Postgres databases. Redis, MySQL and MongoDB are not provided today, so an app that needs one brings its own.

### The disk forgets

Anything written to local disk is gone on the next deploy. Apps that speak S3 get a bucket instead.

### Apps sleep when idle

On every plan, an app nobody is using goes to sleep and the next visit wakes it. The first request took 2.9 to 13.9 seconds in our measurements, depending on the stack. There are no always-on workers, so use a cron job or a webhook for background work.

## Database questions, answered.

Anything else? Write to us and a person answers.

[support@antideploy.com](mailto:support@antideploy.com)

### Do I need a Neon or Supabase account?

No. Antideploy creates the database on its own account and gives your app the connection string. If you set your own `DATABASE_URL`, for example for Supabase, Antideploy leaves it alone and creates nothing.

### Does my data survive a deploy?

Yes. The database belongs to the application and every deploy reuses it. Only the container's disk is replaced.

### Can I see what is in it?

Yes. In the console, the Database tab shows tables, columns and row counts, read-only. Your agent can read up to 50 rows at a time through the API, with credential-like columns hidden. For more, connect with the connection string in your `.env`.

### Can my agent delete the database?

No. It can create one, but dropping a database or deleting its application is only possible in the console.

### Can I use MySQL, MongoDB or Redis?

Antideploy creates Postgres only. Bring your own for anything else and set its credentials as variables.

### Why is the first query slow?

An idle database suspends and wakes on the next query, so the first request after a quiet spell is slower than the rest.

## More guides, and the platform.

Each platform page covers one part of Antideploy: what it does, where it stops and the questions people ask. [See the whole platform](https://antideploy.com/platform), or [all the guides](https://antideploy.com/blog).

- [How to deploy an Express API with a database](https://antideploy.com/blog/how-to-deploy-an-express-api-with-a-database): The start script, the PORT variable, DATABASE_URL, migrations, and the failures to avoid.
- [How to add login to your app](https://antideploy.com/blog/how-to-add-login-to-your-app): Email and password sign-in, with users stored in your own Postgres. What is on and what is not.
- [How to add file uploads to your app](https://antideploy.com/blog/how-to-add-file-uploads-to-your-app): Uploads on disk vanish on every deploy. Ask for a private S3 bucket and upload with any S3 client.

- [Database](https://antideploy.com/platform/database)
- [Environment variables](https://antideploy.com/platform/environment-variables)
- [Deployments](https://antideploy.com/platform/deployments)
- [Console](https://antideploy.com/platform/console)

Facts on this page were checked against the live platform on 7 October 2026.

## Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

To set this up, give your coding agent this sentence:

```text
Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.
```
