Documentation

Developer Guide

Get up and running with Absolute DB — installation, connection strings, and examples in Python, Node.js, Java, Go, Rust, .NET, and WebAssembly.

Installation

macOS (Homebrew)

Shell
brew tap absolutedb/tap
brew install absdb
absdb --version   # Absolute DB (current release) 

Linux (Quick Install)

Shell
curl -fsSL https://downloads.absolutedb.com/install.sh | sh
# Installs absdb and absdb-server to /usr/local/bin/

Docker

Shell
docker run -d \
  --name absdb \
  -p 5433:5433 -p 8080:8080 \
  -v absdb-data:/var/lib/absdb \
  absolutedb/absdb:latest

Build from Source

Shell
git clone git@github.com:supportcall/AbsoluteDB.git
cd AbsoluteDB
make release
# bin/absdb (~154 KB), bin/absdb-server (~230 KB), bin/absdb-lite (~154 KB)

Quick Start

Start the server
# Start server (PostgreSQL wire port 5433 + REST 8080)
absdb-server --data /var/lib/absdb --port 5433

# Embedded CLI (no network, ~154 KB binary)
absdb-lite my_database.db
First queries via psql
psql -h localhost -p 5433 -U admin -d mydb

CREATE TABLE products (
  id    INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  name  TEXT    NOT NULL,
  price REAL    NOT NULL,
  tags  TEXT[]
);

INSERT INTO products (name, price, tags)
VALUES ('Widget Pro', 49.99, ARRAY['hardware','featured']);

SELECT id, name, price FROM products WHERE price < 100 ORDER BY price;
REST quick check
curl -s http://localhost:8080/api/v1/status | jq .
curl -s -X POST http://localhost:8080/api/v1/query \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Basic YWRtaW46c2VjcmV0' \
  -d '{"sql":"SELECT version()"}' | jq .

Connection Strings

ProtocolConnection String
PostgreSQL wirepostgresql://user:pass@host:5433/dbname
PostgreSQL TLSpostgresql://user:pass@host:5433/dbname?sslmode=require
Redis RESP3redis://user:pass@host:6379/0
gRPCgrpc://host:9090 / grpcs://host:9090
RESThttp://host:8080/api/v1/
absdb.conf
host            = 0.0.0.0
port            = 5433
rest_port       = 8080
grpc_port       = 9090
redis_port      = 6379
data_dir        = /var/lib/absdb
max_connections = 500
tls_cert        = /etc/absdb/server.crt
tls_key         = /etc/absdb/server.key

Python — psycopg2

Python
pip install psycopg2-binary

import psycopg2

conn = psycopg2.connect(
    host="localhost", port=5433,
    dbname="mydb", user="admin", password="secret"
)
cur = conn.cursor()

cur.execute("""CREATE TABLE IF NOT EXISTS events (
    id   BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    type TEXT   NOT NULL,
    ts   TIMESTAMP DEFAULT NOW()
)""")

cur.execute("INSERT INTO events (type) VALUES (%s) RETURNING id", ("login",))
row_id = cur.fetchone()[0]
conn.commit()

cur.execute("SELECT id, type, ts FROM events ORDER BY ts DESC LIMIT 5")
for row in cur.fetchall():
    print(row)
conn.close()

SQLAlchemy

Python
from sqlalchemy import create_engine, text
engine = create_engine("postgresql+psycopg2://admin:secret@localhost:5433/mydb")
with engine.connect() as con:
    result = con.execute(text("SELECT COUNT(*) FROM events"))
    print(result.scalar())

Node.js — node-postgres

JavaScript
npm install pg

const { Pool } = require('pg');
const pool = new Pool({
  host: 'localhost', port: 5433,
  database: 'mydb', user: 'admin', password: 'secret'
});

async function main() {
  const client = await pool.connect();
  try {
    const res = await client.query(
      'SELECT id, name, price FROM products WHERE price < $1', [100]);
    console.table(res.rows);

    await client.query('BEGIN');
    await client.query("INSERT INTO events (type) VALUES ($1)", ['purchase']);
    await client.query('COMMIT');
  } finally { client.release(); }
}
main();

Prisma ORM

prisma/schema.prisma
datasource db {
  provider = "postgresql"
  url      = "postgresql://admin:secret@localhost:5433/mydb"
}

Java — JDBC

Java
// pom.xml: org.postgresql:postgresql:42.7.3
import java.sql.*;

public class Example {
  public static void main(String[] args) throws Exception {
    String url = "jdbc:postgresql://localhost:5433/mydb";
    Properties p = new Properties();
    p.setProperty("user", "admin");
    p.setProperty("password", "secret");
    try (Connection c = DriverManager.getConnection(url, p);
         PreparedStatement ps = c.prepareStatement(
             "SELECT id, name FROM products WHERE price < ?")) {
      ps.setDouble(1, 100.0);
      ResultSet rs = ps.executeQuery();
      while (rs.next())
        System.out.printf("id=%d name=%s%n", rs.getLong(1), rs.getString(2));
    }
  }
}

Go — pgx

Go
import (
  "context"; "fmt"
  "github.com/jackc/pgx/v5"
)

func main() {
  ctx := context.Background()
  conn, _ := pgx.Connect(ctx,
    "postgresql://admin:secret@localhost:5433/mydb")
  defer conn.Close(ctx)

  rows, _ := conn.Query(ctx,
    "SELECT id, name, price FROM products WHERE price < $1", 100.0)
  defer rows.Close()
  for rows.Next() {
    var id int64; var name string; var price float64
    rows.Scan(&id, &name, &price)
    fmt.Printf("id=%d name=%s price=%.2f\n", id, name, price)
  }
}

Rust — tokio-postgres

Rust
use tokio_postgres::NoTls;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let (client, conn) = tokio_postgres::connect(
        "host=localhost port=5433 dbname=mydb user=admin password=secret",
        NoTls).await?;
    tokio::spawn(async move { conn.await.unwrap() });

    let rows = client.query(
        "SELECT id, name FROM products WHERE price < $1", &[&100.0f64]).await?;
    for row in rows {
        println!("id={} name={}", row.get::<_, i64>(0), row.get::<_, &str>(1));
    }
    Ok(())
}

.NET — Npgsql

C#
// dotnet add package Npgsql
using Npgsql;

var connStr = "Host=localhost;Port=5433;Database=mydb;Username=admin;Password=secret";
await using var conn = new NpgsqlConnection(connStr);
await conn.OpenAsync();

await using var cmd = new NpgsqlCommand(
    "SELECT id, name, price FROM products WHERE price < @max", conn);
cmd.Parameters.AddWithValue("max", 100.0);

await using var reader = await cmd.ExecuteReaderAsync();
while (await reader.ReadAsync())
    Console.WriteLine($"{reader.GetInt64(0)} {reader.GetString(1)} {reader.GetDouble(2):F2}");

Embedding as a C Library

Link against build/libabsdb.a for zero-network embedded use. The lite binary is ~154 KB — smaller than DuckDB, more capable than SQLite.

C
#include "absolute.h"

int main(void) {
    absdb_t *db;
    absdb_open("app.db", ABSDB_OPEN_CREATE, &db);
    absdb_exec(db,
        "CREATE TABLE IF NOT EXISTS kv (key TEXT PRIMARY KEY, val TEXT)",
        NULL, NULL, NULL);
    absdb_exec(db, "INSERT INTO kv VALUES ('greeting', 'hello')", NULL,NULL,NULL);

    absdb_stmt_t *stmt;
    absdb_prepare(db, "SELECT val FROM kv WHERE key = ?", -1, &stmt, NULL);
    absdb_bind_text(stmt, 1, "greeting", -1);
    if (absdb_step(stmt) == ABSDB_ROW)
        printf("%s\n", absdb_column_text(stmt, 0));
    absdb_finalize(stmt);
    absdb_close(db);
    return 0;
}
// gcc -O2 app.c -I./include -L./build -labsdb -lpthread -lm -o app

WebAssembly (Browser / Cloudflare Workers)

TypeScript / Cloudflare Worker
import { AbsDB } from '@absolutedb/wasm';

const db = await AbsDB.open({ kv: env.MY_KV_NAMESPACE });
await db.exec(`CREATE TABLE IF NOT EXISTS sessions (
  id TEXT PRIMARY KEY, data JSONB, ts TIMESTAMP DEFAULT NOW()
)`);
const rows = await db.query(
  'SELECT data FROM sessions WHERE id = $1', [sessionId]);
return Response.json(rows[0]?.data ?? null);
Browser (ESM)
<script type="module">
import { AbsDB } from 'https://cdn.absolutedb.com/latest/absdb.esm.js';
const db = await AbsDB.open({ name: 'myapp', persist: 'indexeddb' });
await db.exec("CREATE TABLE IF NOT EXISTS notes (id INTEGER PRIMARY KEY, body TEXT)");
await db.exec("INSERT INTO notes (body) VALUES (?)", ["Hello!"]);
const rows = await db.query("SELECT * FROM notes");
console.table(rows);
</script>

ORM Compatibility

ORM / FrameworkLanguageDriver Setting
Django ORMPythonENGINE: django.db.backends.postgresql
SQLAlchemyPythonpostgresql+psycopg2://...
Rails ActiveRecordRubyadapter: postgresql
PrismaNode.jsprovider = "postgresql"
SequelizeNode.jsdialect: 'postgres'
GORMGogorm.io/driver/postgres
HibernateJavadialect: PostgreSQLDialect
Entity Framework.NETNpgsql EF Core provider

Vector Search Example

Python — Semantic Search
import psycopg2, numpy as np

conn = psycopg2.connect("postgresql://admin:secret@localhost:5433/mydb")
cur = conn.cursor()

cur.execute("""CREATE TABLE IF NOT EXISTS docs (
    id        INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    content   TEXT,
    embedding VECTOR(1536)
)""")
cur.execute("CREATE INDEX IF NOT EXISTS docs_hnsw ON docs USING hnsw (embedding)")

embedding = np.random.rand(1536).tolist()
cur.execute("INSERT INTO docs (content, embedding) VALUES (%s, %s::vector)",
    ("Absolute DB is the fastest database.", embedding))
conn.commit()

query_vec = np.random.rand(1536).tolist()
cur.execute("""SELECT id, content, embedding <-> %s::vector AS dist
    FROM docs ORDER BY dist LIMIT 5""", (query_vec,))
for row in cur.fetchall():
    print(f"id={row[0]} dist={row[2]:.4f} {row[1][:60]}")

Migration from PostgreSQL / MySQL / MongoDB

absdb-migrate CLI
# From PostgreSQL
absdb-migrate \
  --from postgres \
  --src "postgresql://user:pass@pg-host:5432/mydb" \
  --dst "postgresql://admin:secret@localhost:5433/mydb" \
  --include-schema --include-indexes --include-constraints

# From MySQL
absdb-migrate \
  --from mysql \
  --src "mysql://user:pass@mysql-host:3306/mydb" \
  --dst "postgresql://admin:secret@localhost:5433/mydb"

# From MongoDB
absdb-migrate \
  --from mongodb \
  --src "mongodb://host:27017/mydb" \
  --dst "postgresql://admin:secret@localhost:5433/mydb" \
  --collection users

Continue Reading

Quick Start SQL Reference API Reference

Ready to run Absolute DB?

~154 KB binary  ·  zero external dependencies  ·  2,737 tests passing  ·  SQL:2023 100%

Download Free → View Pricing All Docs