Getting Started
This page shows you how to create a Sliplane database and connect to it from your application in the fastest way.
Create a database
Section titled “Create a database”To create a database, follow these steps:
-
In the Sliplane dashboard, go to Databases.
-
Click Create Database.
-
Choose a name, region, compute size, and storage size. See Pricing for what each option costs.
-
Click Create Database.
Your database is ready to use once it finishes provisioning which takes around 30 seconds. Open it to find its connection details.
Connect to your database
Section titled “Connect to your database”You can connect to your database using any PostgreSQL client, including command-line tools, language drivers, and graphical clients. All connections to Sliplane databases support TLS encryption. For protection against man-in-the-middle attacks, connect with sslmode=verify-full, which validates our certificate and hostname.
Configure the environment
Section titled “Configure the environment”The fastest way to connect to your database is to use the Connection URI, which contains all the information needed to connect.
postgres://jonas:pAsSworD123@xxxxxx.sliplane.app:1234/mydb?sslmode=verify-full&sslrootcert=system ^ ^ ^ ^ ^ user -| | |- host port -| |- database | |- passwordCopy the Connection URI from the Sliplane dashboard where your database is located and set it as an environment variable DATABASE_URL.
export DATABASE_URL="postgres://USER:PASSWORD@HOST:PORT/DATABASE?sslmode=verify-full&sslrootcert=system"setx DATABASE_URL "postgres://USER:PASSWORD@HOST:PORT/DATABASE?sslmode=verify-full&sslrootcert=system"$Env:DATABASE_URL="postgres://USER:PASSWORD@HOST:PORT/DATABASE?sslmode=verify-full&sslrootcert=system"Quick starts
Section titled “Quick starts”With the environment variable in place, you can connect from the psql CLI, any PostgreSQL driver, or ORMs. Here are a few examples to get you started.
# Connect to your databasepsql "$DATABASE_URL"
# Or run a single querypsql "$DATABASE_URL" -c "SELECT version();"import { Client } from "pg"
const client = new Client({ connectionString: process.env.DATABASE_URL })await client.connect()
const { rows } = await client.query("SELECT * from pg_stat_ssl")console.log(rows[0]) // { ssl: true, ... }
await client.end()import postgres from "postgres"
const client = postgres(process.env.DATABASE_URL)
const [ ssl ] = await client`SELECT * from pg_stat_ssl`console.log(ssl) // { ssl: true, ... }
await client.end()import { drizzle } from "drizzle-orm/postgres-js"import { sql } from "drizzle-orm"import postgres from "postgres"
const client = postgres(process.env.DATABASE_URL)const db = drizzle(client)
const result = await db.execute(sql`SELECT * from pg_stat_ssl`)console.log(result[0]) // { ssl: true, ... }
await client.end()import osimport psycopg
with psycopg.connect(os.environ["DATABASE_URL"]) as conn: with conn.cursor() as cur: cur.execute("SELECT version()") print(cur.fetchone())package main
import ( "context" "fmt" "os"
"github.com/jackc/pgx/v5")
func main() { ctx := context.Background()
conn, _ := pgx.Connect(ctx, os.Getenv("DATABASE_URL")) defer conn.Close(ctx)
var version string conn.QueryRow(ctx, "SELECT version()").Scan(&version) fmt.Println(version)}export PGHOST="YOUR_DATABASE_HOST"export PGPORT="YOUR_DATABASE_PORT"export PGDATABASE="DATABASE_NAME"export PGUSER="USERNAME"export PGPASSWORD="PASSWORD"setx PGHOST YOUR_DATABASE_HOSTsetx PGPORT YOUR_DATABASE_PORTsetx PGDATABASE DATABASE_NAMEsetx PGUSER USERNAMEsetx PGPASSWORD PASSWORD$Env:PGHOST="YOUR_DATABASE_HOST"$Env:PGPORT="YOUR_DATABASE_PORT"$Env:PGDATABASE="DATABASE_NAME"$Env:PGUSER="USERNAME"$Env:PGPASSWORD="PASSWORD"import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.Statement;import java.util.Properties;
public class HelloPostgres { public static void main(String[] args) throws Exception { String url = String.format( "jdbc:postgresql://%s:%s/%s", System.getenv("PGHOST"), System.getenv("PGPORT"), System.getenv("PGDATABASE"));
Properties props = new Properties(); props.setProperty("user", System.getenv("PGUSER")); props.setProperty("password", System.getenv("PGPASSWORD")); props.setProperty("sslmode", "verify-full"); props.setProperty("sslfactory", "org.postgresql.ssl.DefaultJavaSSLFactory");
try (Connection conn = DriverManager.getConnection(url, props); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM pg_stat_ssl;")) { if (rs.next()) { System.out.println(rs.getString("ssl")); // "t" } } }}Detailed guides
Section titled “Detailed guides”The following table lists the official documentation for popular PostgreSQL drivers and ORMs.
| Language or framework | Library |
|---|---|
| JavaScript / TypeScript | node-postgres (pg) |
| JavaScript / TypeScript | postgres.js |
| JavaScript / TypeScript | Drizzle ORM |
| JavaScript / TypeScript | Prisma ORM |
| Python | psycopg |
| Go | pgx |
| Java | PostgreSQL JDBC Driver |
| .NET | Npgsql |
| Ruby | pg gem |
| PHP | PDO_PGSQL |
| Rust | sqlx / tokio-postgres |
| Laravel | Eloquent PostgreSQL driver |
| Django | django.db.backends.postgresql |
Connect with a GUI
Section titled “Connect with a GUI”Prefer a graphical client? Follow one of these quickstarts to connect with your database’s connection details.