Skip to main content

Quick Start

This tutorial will show you how to create and query your first Platter Postgres database with the platter CLI.

Choose one of the connection methods below to get started.

Prerequisites#

To interact with your database through a connection string, an installation of psql is recommended.

Setting Up the Project#

  1. Make sure that you've signed up for a Platter account. To create databases and branches, you'll also need to add a payment method. See more about our pricing here.

  2. Install the platter CLI with cURL.

  3. Log in with your Platter email and password with:

    platter identity login

Setting Up Postgres#

  1. Once you've installed platter, then you can create or branch (see Concepts to learn more about feature branching) any Platter resource. Run the following command to create your first instance:

    platter postgres create my-new-database
  2. Your new instance was created with a "trunk" branch. Future branches will be based off of this branch by default. This branch was given a name based on your local git configuration, falling back to main if no git configuration exists on your machine. To check the name of your new instance's trunk branch, list your instances:

    platter postgres list

    This should give you a list that looks something like this:

    +--------------------------------------+-------------------------------+--------------+
    | ID | NAME | TRUNK BRANCH |
    +--------------------------------------+-------------------------------+--------------+
    | f1b19a32-1334-406c-a792-ad2905289435 | my-new-database | main |
    +--------------------------------------+-------------------------------+--------------+

Using psql#

  1. If you have psql installed, you can use the url command to connect directly to the trunk branch of your database instance:

    psql $(platter postgres branch url main -i my-new-database)
  2. Once you've connected with psql, you can interact with your main branch's database directly. Try running the following commands to create an items table:

    CREATE TABLE IF NOT EXISTS items (
    id SERIAL PRIMARY KEY,
    name TEXT NOT NULL
    );
    INSERT INTO items (name)
    VALUES ('my-new-item')
    RETURNING id, name;
  3. Both commands should run succesffully, and subsequent queries to items should return my-new-item.

Next Steps#

Congratulations! You now have a database that can be used anywhere, from the command-line to serverless functions. You also have a database that is public and easy-to-access for identified users, but still protected against malicious queries. And you've completely eliminated the need to manage your own servers, connection pools, cloud databases, or deployment processes along the way. Here's where to go from this point:

  1. To learn more about how to create and discard copies of your database as you work on features check out Branching
  2. To dive right into some practical examples, check out the Migrations and Netlify Functions guides.