Skip to content

CLI Reference — `hmdb`

The hmdb command-line tool is installed automatically by pip install -e ..

hmdb [--version] COMMAND [options] DB_DIR [...]

OptionDescription
--versionPrint version and exit
--helpShow help and exit

Build the TPI+FMI index from CSV source files. Must be run before any other command.

Terminal window
hmdb import DB_DIR --edges FILE [--nodes FILE] [--bucket-seconds N]

Options

OptionDefaultDescription
--edges FILErequiredPath to hyperedges CSV
--nodes FILEPath to node-properties CSV (optional)
--bucket-seconds N10TPI time-bucket width in seconds

Hyperedges CSV columns: event_ts, members, member_count, weight, mean_dist_m, formation

Example

Terminal window
hmdb import ./my_db \
--edges server/swarm_data/hyperedges.csv \
--nodes server/swarm_data/nodes_drone.csv \
--bucket-seconds 10

Print database statistics and list hyperedge tables.

Terminal window
hmdb info DB_DIR

Example output

Database directory : /path/to/my_db
Total records : 1,774
Bucket count : 86
Bucket seconds : 10
Unique nodes : 20
WAL pending : 0

Start an interactive Cypher query shell with readline history.

Terminal window
hmdb shell DB_DIR

Special commands inside the shell

CommandDescription
HELP or ?Show help
QUIT or EXITExit
.tablesShortcut for CALL show_hyperedge_tables()
.infoShow database statistics
.compactCompact WAL into TPI+FMI

Command history is saved to ~/.hmdb_history across sessions.


Execute a single Cypher query and print results to stdout.

Terminal window
hmdb query DB_DIR CYPHER [--format {table|csv}]

Options

OptionDefaultDescription
--formattableOutput format: table (Unicode box-drawing) or csv

Examples

Terminal window
# Unicode table output
hmdb query ./my_db \
"MATCH HYPEREDGE (he:CoProximity) WHERE he.event_ts >= 0 AND he.event_ts <= 100 RETURN *"
# CSV output (pipe-friendly)
hmdb query ./my_db \
"CALL show_hyperedge_tables() RETURN *" \
--format csv

Execute a query and write the full result set to a CSV file.

Terminal window
hmdb export DB_DIR --query CYPHER --output FILE

Options

OptionDescription
--query CYPHERQuery to execute (required)
--output FILEDestination CSV file path (required)

Example

Terminal window
hmdb export ./my_db \
--query "MATCH HYPEREDGE (he:CoProximity) RETURN *" \
--output full_dump.csv

Insert a single hyperedge record into the WAL.

Terminal window
hmdb insert DB_DIR --ts N --members N1,N2,... [options]

Options

OptionDefaultDescription
--ts NrequiredEvent timestamp in seconds
--members N1,N2,...requiredComma-separated member node IDs
--weight F0.0Coalition weight (0–1)
--mean-dist F0.0Mean pairwise distance in metres
--formation NAME''Formation name string

Example

Terminal window
hmdb insert ./my_db --ts 9999 --members 1,2,3 --weight 0.95 --formation WEDGE

Compact all WAL entries into the TPI+FMI binary index and truncate the WAL.

Terminal window
hmdb compact DB_DIR

After compact, wal_pending returns 0. Run periodically when wal_pending grows large (rule of thumb: > 10 % of total_records).

Example

Terminal window
hmdb compact ./my_db
# Compacting 47 WAL entries … done (8.3ms)
# WAL pending after compact: 0