Docs
Skip to content

PostgreSQL

Quick start_

Create your first native PostgreSQL database in the Appwrite Console, run your first queries in the SQL editor, and connect with psql.

2 min read

Raw

You can create a PostgreSQL database and run your first query in a few minutes.

Create a database

  1. In your project, go to Databases.
  2. Click Create database.
  3. Under Choose database type, select PostgreSQL from the Native databases group.
  4. Give your database a name, and optionally a custom database ID. This step appears once you pick a type.

Create database type selection
Create database type selection

  1. Under Specifications, select your preferred tier.
  2. Optionally configure Read replicas and Point-in-time recovery (PITR). You can change both later.

Database specifications
Database specifications

  1. Review the database summary and click Create database.

Your database starts provisioning and becomes ready shortly after. You land in the SQL editor once it is created.

Run your first queries

SQL editor
SQL editor

The SQL editor tab gives you an editor with formatting, query explain, and a results panel, without leaving the browser.

The editor runs one statement per query, so run these three in turn rather than pasting them together.

Create a table:

SQL
CREATE TABLE books (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
author TEXT NOT NULL
);

Insert a row:

SQL
INSERT INTO books (title, author)
VALUES ('The Hitchhiker''s Guide to the Galaxy', 'Douglas Adams');

Read it back:

SQL
SELECT * FROM books;

Get your connection details

To connect from outside the Console:

  1. Open your database and click Credentials.
  2. The Details tab shows the host, port, username, password, and database name.
  3. The DSN, .env, Prisma, Drizzle, and psql tabs have ready-made snippets for each workflow.

Connect with psql

Copy the command from the psql tab of the credentials dialog, or build it from the details. The port shown there is 6432, the connection pooler, which is what you want for everyday use:

Bash
PGSSLMODE=require psql -h <host> -p 6432 -U admin -d <database>

Port 5432 reaches the database directly, bypassing the pooler. Use it for migrations and other work that needs one session for the whole run.

Enter the password when prompted. You can run the same queries from your terminal that you ran in the SQL editor, or connect from your application with any PostgreSQL driver. See Connections for driver examples.

Next steps

Was this page helpful?

Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.