Get started
Quickstart
Create a Database and a Credential, put one variable in .env and run your first query in about three minutes.
You need a NordBase Account with a Plan. Every Plan, including Start at €5 a month excluding VAT, can run one SQL or Document Database.
1. Create a Database
In the console, choose New database and fill in four fields:
| Field | What to pick | Example |
|---|---|---|
| Name | Letters, digits, spaces, ., _ or -, up to 63 characters | shop-production |
| Engine | SQL (PostgreSQL) or Document (MongoDB-compatible) | SQL |
| Region | Where the Primary runs. This becomes the Home region | fi-hel (Helsinki) |
| Size | The compute the Instance gets, taken from your Pool | nano |
Choose Create. The Database gets an id such as db-k7q2x9m4p1 and its status moves from provisioning to available. SQL Databases run PostgreSQL 18 unless you pick 16 or 17.
You can change the Size later. See Plans and limits for what each Size gets.
2. Create a Credential
A Credential is what your software uses to connect: an id, a secret and a Permission set. Open the Database, go to Credentials and choose New credential.
For this quickstart, name it local-dev and choose the schema preset, so it can create a table and change rows. For production, give your app a read_write Credential and keep schema for migrations. See Credentials.
When you choose Create, the console shows:
- the Connection URL, which holds the Credential id
cr_4k2m8p0d9aand its secretnbs_…; - a key file you can download, a JSON file with the same details.
The secret is shown once. NordBase stores only a verifier, so it cannot show the secret again. If you lose it, rotate the Credential.
3. Put the Connection URL in .env
# .env
NORDBASE_URL="postgresql://cr_4k2m8p0d9a:nbs_…@db-k7q2x9m4p1.fi-hel.nordbase.<base>:5432/db-k7q2x9m4p1?sslmode=verify-full&sslrootcert=system"Copy the exact value from the console. Add .env to .gitignore so the secret never reaches your repository. Every NordBase library reads NORDBASE_URL, and nothing else is needed.
4. Run your first query
The three examples do the same thing: create a customers table if it is not there, add one row and read it back. Every value goes to the Database as a parameter, not as SQL text.
Node
npm i nordbase// index.mjs
import { createClient } from 'nordbase'
const db = createClient() // reads NORDBASE_URL
await db.sql`
create table if not exists customers (
id bigint generated always as identity primary key,
email text not null unique,
name text not null
)
`
const email = '[email protected]'
const name = 'Ana Moreno'
await db.sql`insert into customers (email, name) values (${email}, ${name}) on conflict (email) do nothing`
const rows = await db.sql`select id, email, name from customers where email = ${email}`
console.log(rows)
// The same kind of Read with the builder
const latest = await db.from('customers').select('id, email').order('id', { desc: true }).limit(5)
console.log(latest)node --env-file=.env index.mjsPython
pip install nordbase # or: uv add nordbase# main.py (Python 3.14 or newer, for t-strings)
from nordbase import connect
db = connect() # reads NORDBASE_URL
db.sql(t"""
create table if not exists customers (
id bigint generated always as identity primary key,
email text not null unique,
name text not null
)
""")
email = "[email protected]"
name = "Ana Moreno"
db.sql(t"insert into customers (email, name) values ({email}, {name}) on conflict (email) do nothing")
rows = db.sql(t"select id, email, name from customers where email = {email}")
print(rows)
# The same kind of Read with the builder (from_ because from is a Python keyword)
latest = db.from_("customers").select("id, email").order("id", desc=True).limit(5).execute()
print(latest)On Python older than 3.14, pass the values by name instead of using a t-string:
rows = db.sql("select id, email, name from customers where email = {email}", email=email)uv run --env-file .env main.pyRust
cargo add nordbase
cargo add tokio --features full// src/main.rs
use nordbase::{sql, Client};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let db = Client::from_env()?; // reads NORDBASE_URL
db.query(sql!(
"create table if not exists customers (
id bigint generated always as identity primary key,
email text not null unique,
name text not null
)"
))
.await?;
let email = "[email protected]";
let name = "Ana Moreno";
db.query(sql!(
"insert into customers (email, name) values ({email}, {name}) on conflict (email) do nothing"
))
.await?;
let rows = db
.query(sql!("select id, email, name from customers where email = {email}"))
.await?;
println!("{rows:?}");
// The same kind of Read with the builder
let latest = db.from("customers").select("id, email").limit(5).await?;
println!("{latest:?}");
Ok(())
}set -a && source .env && set +a && cargo runThe sql! macro turns {email} into a $1 parameter at compile time. A query built at runtime from a plain string does not compile.
5. Or use any driver and ORM
The Connection URL is a standard PostgreSQL URL, so tools you already use take it unchanged.
psql
psql "postgresql://cr_4k2m8p0d9a:nbs_…@db-k7q2x9m4p1.fi-hel.nordbase.<base>:5432/db-k7q2x9m4p1?sslmode=verify-full&sslrootcert=system"psql and other tools built on libpq look for a root certificate file in your home folder by default. sslrootcert=system (libpq 16 or newer) tells them to use your system's trusted certificates, which is all NordBase needs.
Prisma and Drizzle
ORMs read the Connection URL from an environment variable. Use the routed port 5432 for your app and the Direct port 5433 for migrations, because migrations need a session that stays on the Primary:
# .env
# App queries: routed port, transaction pooling
DATABASE_URL="postgresql://cr_4k2m8p0d9a:nbs_…@db-k7q2x9m4p1.fi-hel.nordbase.<base>:5432/db-k7q2x9m4p1?sslmode=verify-full&sslrootcert=system"
# Migrations: Direct port, always the Primary
DIRECT_URL="postgresql://cr_4k2m8p0d9a:nbs_…@db-k7q2x9m4p1.fi-hel.nordbase.<base>:5433/db-k7q2x9m4p1?sslmode=verify-full&sslrootcert=system"import { drizzle } from 'drizzle-orm/node-postgres'
const orm = drizzle(process.env.DATABASE_URL!)Prepared statements work on both ports. Give your ORM's migration command (prisma migrate deploy, drizzle-kit migrate) the Direct URL.
Document Databases
For a Document Database the Connection URL starts with mongodb://, and the official MongoDB drivers and mongosh take it unchanged:
mongosh "mongodb://cr_4k2m8p0d9a:nbs_…@db-k7q2x9m4p1.fi-hel.nordbase.<base>:27017/?tls=true&authMechanism=SCRAM-SHA-256"See Document Databases.
Where to go next
- Understand the URL and the ports: Connection URL.
- Write queries that cannot be injected: Safe SQL.
- Give your app its own least-privilege Credential: Credentials.
- Let your coding agent manage NordBase: MCP server.