Airplane Postgres

Easily provision a Postgres database
Airplane Postgres is a managed Postgres database powered by Neon. Whether you need a lightweight database to store data between tasks or a full-fledged database to power your application, Airplane Postgres provides a simple, easy-to-use interface to get started.
Some benefits over using a self-hosted database:
  • No setup required - Airplane will provision and configure a Postgres database for you.
  • Easily import data - Import data from CSV files or run SQL queries to seed your database.
  • Automatically integrate with Airplane - Start using Airplane Postgres in your tasks immediately.
Once you have your database set up, you can use it in your tasks and runbooks.

Creating an Airplane Postgres resource

To create a new Airplane Postgres resource, visit your team's resources page, click the New button, and select the Airplane Postgres resource type.
Name should be a human-readable name for your resource.

Importing data

Once you have created your Airplane Postgres resource, you can import data into your database by writing a SQL query, or by uploading a CSV file.

Run a Postgres query

On the resource settings page, you can run a SQL query to create a table and insert data into it.
You can also connect to the database directly and run any custom operation.

Import from CSV

Alternatively, you can upload a CSV file of your data to automatically create tables and insert data. Airplane will automatically detect the column types.
To use this feature, navigate to your Airplane Postgres resource and click the Seed new table from CSV button.
For each CSV file you upload, you will be prompted to select a table name. Each column in the header row will be used as the column name for the table.

Supported column types

The following column types will automatically be inferred from the CSV contents:
  • boolean
  • bigint
  • double
  • float
  • integer
  • time
  • date
  • timestamptz
  • text
To specify a column type override, add the type in parentheses after the column name. For example, the column name age (integer) will override the column type to be integer.

Example CSV file

This CSV file:
Alice,22,2023-02-15 15:30:45
Bob,21,2023-02-13 12:30:45
Will create a table with the following columns:
  • name text
  • age bigint
  • created_at timestamptz
In this example, to override the age column to be an int instead of bigint, you would add the type after the column name like this:
name,age (int),created_at
Alice,22,2023-02-15 15:30:45
Bob,21,2023-02-13 12:30:45

Using Airplane Postgres in tasks and runbooks

Just like any other Airplane resource, you can issue SQL queries against your Airplane Postgres resource from tasks by using the SQL SDK or by writing a SQL task.

Connecting to the database directly

You can manually inspect or modify your database directly using your favorite Postgres client by using the connection string provided on the resource settings page.
For example, you can connect to the database using the psql command line tool:
psql "postgres://admin:*****"

Local development with Airplane Studio

While developing a task locally that is attached to an Airplane Postgres resource, you may want to modify the database without affecting the production version of the database. To do this, you can create a copy of your Airplane Postgres resource in the Airplane Studio.
Creating a copy provisions a new database for local development and copies over data from the remote resource. Any changes you make to your local copy of this database will not affect the remote version of the database.
To create a local copy, navigate to the Resources tab in the studio. Find the remote Airplane Postgres resource you want to sync, and click the Create local copy... button.
This local copy will take take precedence over the remote version of this resource. See the Airplane Studio reference for more information.

Field reference

When this resource is attached to a task, its fields are available in the JSON environment variable AIRPLANE_RESOURCES under the alias it was attached with. For more information, see the PostgreSQL field reference.