Getting Started with PackDB

Install PackDB and run your first optimization query.

1 Prerequisites

Requirements depend on your installation method:

Binary Downloads (Recommended)

No prerequisites. PackDB binaries are self-contained.

Building from Source

  • C++ Compiler: GCC 9+, Clang 10+, or MSVC 2019+
  • CMake: Version 3.15+
  • Python: Version 3.7+ (parser generation)
  • Git: For cloning the repository
  • Make or Ninja: Build system

Supported Platforms

  • Linux x86-64 (Ubuntu 18.04+)
  • macOS 11.0+ (Intel & Apple Silicon)
  • Windows 10+ (x64)
Development Status

PackDB is in active development. The hatim branch contains the stable prototype.

2 Installation

Step 1: Choose Your Platform

Platform Requirements Filename
Linux x86-64 Ubuntu 18.04+, CentOS 7+ packdb_cli-linux-amd64.zip
macOS Universal macOS 11.0+ packdb_cli-osx-universal.zip
Windows x64 Windows 10+ packdb_cli-windows-amd64.zip

.gz archives are also available for Linux and macOS in the release assets.

Step 2: Download from GitHub Releases

Latest Release

Download the ZIP file for your platform from the Assets section.

Step 3: Extract and Verify

Linux / macOS

Bash
# Extract the downloaded file (adjust filename for your platform)
unzip packdb_cli-linux-amd64.zip

# Make executable
chmod +x packdb

# Verify installation
./packdb --version

Windows (PowerShell)

PowerShell
# Extract ZIP file using File Explorer or:
Expand-Archive packdb_cli-windows-amd64.zip -DestinationPath .

# Verify installation
.\packdb.exe --version
Unsigned Binaries

macOS: Right-click → Open → confirm.

Windows: SmartScreen → "More info" → "Run anyway".

Step 4: Test Installation

Bash
# Test basic query
./packdb -c "SELECT 'PackDB is ready!' as message;"

3 Your First Query

A classic knapsack problem: select items to maximize value within a weight limit.

Start PackDB

Bash
# Start PackDB with a new database
./packdb my_database.db

This opens an interactive SQL shell. You can also use ./packdb without a filename for an in-memory database.

Create Sample Data

In the PackDB shell, run:

SQL
CREATE TABLE Items (
    id INTEGER,
    value INTEGER,
    weight INTEGER,
    category VARCHAR
);

INSERT INTO Items VALUES
    (1, 100, 20, 'electronics'),
    (2, 60, 10, 'electronics'),
    (3, 120, 30, 'electronics'),
    (4, 50, 50, 'furniture');

Write the Optimization Query

SQL
SELECT id, value, weight, x
FROM Items
WHERE category = 'electronics'
DECIDE x
SUCH THAT
    x IS BINARY,
    SUM(x * weight) <= 50
MAXIMIZE SUM(x * value);

What Each Clause Does

  1. 1
    WHERE category = 'electronics' — Only electronics are considered. Item 4 (furniture) is excluded.
  2. 2
    DECIDE x — Creates a variable x for each remaining row.
  3. 3
    SUCH THAT x IS BINARY, SUM(x * weight) <= 50 — Each x is 0 or 1, and the total weight of selected items cannot exceed 50.
  4. 4
    MAXIMIZE SUM(x * value) — Pick the combination with the highest total value.

Expected Output

id value weight x
1 100 20 1
2 60 10 0
3 120 30 1

Result: Items 1 and 3 are selected (x = 1). Their combined weight is exactly 50 (at the limit) and their combined value is 220 — the highest achievable. Item 2 is skipped (x = 0) because including it would push the total weight to 60.

Alternative: Run from Command Line

You can also run queries directly from your terminal without entering the interactive shell:

Bash
# Run a query file
./packdb my_database.db -f query.sql

# Or execute inline
./packdb my_database.db -c "SELECT * FROM Items;"