Quickstart
From no database to a connected application
This takes a few minutes and leaves you with a database, a login for your application, and a connection URL that works.
1. Create the database
Go to Database Service in the console and choose Create database.
You are asked for three things:
- a name, which is the PostgreSQL database name, so lowercase letters, numbers and underscores, starting with a letter
- a region, which decides where the data lives and cannot be changed later
- a PostgreSQL version, which defaults to the newest available
Creating takes a short while. The database appears in the list immediately and reports its progress while the cluster is provisioned.
2. Create a login for your application
Open the database, go to Users, and choose Create app user.
Give it a name and leave the capability on Read and write, which is what an application normally needs. A password is generated for you.
Do not connect your application as yourself. An app user is a login you can revoke, expire and restrict without touching anyone else's access.
3. Open the database to your application
A new database is closed to the internet. Nothing outside the cluster can reach it until you say so.
On the database page, under Internet access, turn it on and add the address ranges that are
allowed to connect, in CIDR notation. A single address is written 203.0.113.7/32; a range is
written 203.0.113.0/24.
Add the addresses your application actually connects from. If you do not know them yet, Connecting explains how to find out and what the alternatives are.
4. Connect
Open the app user you created. Its page carries a connection URL in the form PostgreSQL expects, with everything but the password visible:
postgresql://orders_api:••••••••@orders.hub-cae1-a.ca-east-1.hiveops.io:5432/orders_prodReveal the password to read it, or copy the whole URL, which copies the real password whether or not it is on screen.
With psql:
psql "postgresql://orders_api:[email protected]:5432/orders_prod"From an application, put the same URL in the environment variable your driver reads, usually
DATABASE_URL.
What next
- Schemas and tables to create the structure your application needs.
- Querying to run SQL from the console rather than a terminal.
- App users to understand what each capability grants before you create the next login.