Documents
cli-reference
cli-reference
Type
External
Status
Published
Created
Mar 4, 2026
Updated
Apr 5, 2026
Updated by
Dosu Bot
Source
View

CLI Reference#

Complete reference for all DBSurveyor command-line options.

dbsurveyor-collect#

Database schema collection tool.

Synopsis#

dbsurveyor-collect [OPTIONS] [DATABASE_URL]
dbsurveyor-collect <COMMAND>

Global Options#

OptionShortDescription
--verbose-vIncrease verbosity (-v, -vv, -vvv)
--quiet-qSuppress all output except errors
--help-hPrint help information
--version-VPrint version information

Collection Options#

OptionDescriptionDefaultStatus
--database-url <URL>Database connection stringFrom DATABASE_URL env var✅ Implemented
--output <PATH>Output file pathschema.dbsurveyor.json✅ Implemented
--sample <N>Number of sample rows per table100🚧 Planned
--throttle <MS>Delay between operations (ms)None🚧 Planned
--compressCompress output using Zstandardfalse✅ Implemented
--encryptEncrypt output using AES-GCMfalse✅ Implemented
--enable-qualityEnable data quality analysis on sampled datafalse✅ Implemented
--quality-threshold <LIST>Quality thresholds (e.g., completeness:0.9,uniqueness:0.95,consistency:0.85)None✅ Implemented
--all-databasesCollect all accessible databasesfalse🚧 Planned
--include-system-databasesInclude system databasesfalse🚧 Planned
--exclude-databases <LIST>Comma-separated list to excludeNone🚧 Planned

Commands#

collect#

Collect schema from database.

dbsurveyor-collect collect <DATABASE_URL> [--output <PATH>]

test#

Test database connection without collecting schema.

dbsurveyor-collect test <DATABASE_URL>

list#

List supported database types and connection formats.

dbsurveyor-collect list

Examples#

# Basic collection
dbsurveyor-collect postgres://user:pass@localhost/db

# With custom output file
dbsurveyor-collect --output my-schema.json postgres://localhost/db

# Encrypted and compressed
dbsurveyor-collect --encrypt --compress postgres://localhost/db

# Multi-database collection
dbsurveyor-collect --all-databases --exclude-databases postgres,template0 postgres://localhost

# Test connection only
dbsurveyor-collect test mysql://root:password@localhost/mydb

# Throttled collection (stealth mode)
dbsurveyor-collect --throttle 1000 postgres://localhost/db

Connection String Formats#

DatabaseFormatExampleStatus
PostgreSQLpostgres://user:pass@host:port/dbpostgres://admin:secret@localhost:5432/mydb✅ Implemented
SQLitesqlite:///path/to/filesqlite:///home/user/data.db✅ Implemented
MySQLmysql://user:pass@host:port/dbmysql://root:password@localhost:3306/mydb🚧 In Development
MongoDBmongodb://user:pass@host:port/dbmongodb://admin:secret@localhost:27017/mydb🚧 Planned
SQL Servermssql://user:pass@host:port/dbmssql://sa:password@localhost:1433/mydb🚧 Planned

Environment Variables#

VariableDescription
DATABASE_URLDefault database connection string
RUST_LOGLogging configuration (error, warn, info, debug, trace)
DBSURVEYOR_MAX_CONNECTIONSMaximum connection pool size (default: 10)
DBSURVEYOR_MIN_IDLE_CONNECTIONSMinimum idle connections in pool (default: 2)
DBSURVEYOR_CONNECT_TIMEOUT_SECSConnection timeout in seconds (default: 30)
DBSURVEYOR_IDLE_TIMEOUT_SECSIdle connection timeout in seconds (default: 600)
DBSURVEYOR_MAX_LIFETIME_SECSMaximum connection lifetime in seconds (default: 3600)

dbsurveyor#

Database schema documentation and analysis tool.

Synopsis#

dbsurveyor [OPTIONS] [INPUT_FILE]
dbsurveyor <COMMAND>

Global Options#

OptionShortDescription
--verbose-vIncrease verbosity (-v, -vv, -vvv)
--quiet-qSuppress all output except errors
--help-hPrint help information
--version-VPrint version information

Documentation Options#

OptionShortDescriptionDefault
--format <FORMAT>-fOutput formatmarkdown
--output <PATH>-oOutput file pathAuto-detected
--redact-mode <MODE>Data redaction levelbalanced
--no-redactDisable all data redactionfalse

Output Formats#

FormatDescriptionExtensionStatus
markdownMarkdown documentation.md✅ Implemented
jsonJSON analysis report.json✅ Implemented
htmlHTML report with search.html🚧 Placeholder
mermaidMermaid ERD diagram.mmd🚧 Placeholder

Redaction Modes#

ModeDescription
noneNo redaction (show all data)
minimalMinimal redaction (only obvious sensitive fields)
balancedBalanced redaction (recommended default)
conservativeConservative redaction (maximum privacy)

Commands#

generate#

Generate documentation from schema file.

dbsurveyor generate <INPUT_FILE> [OPTIONS]

Options:

  • --format <FORMAT> - Output format
  • --output <PATH> - Output file path

analyze#

Analyze schema for insights and statistics.

dbsurveyor analyze <INPUT_FILE> [--detailed]

Options:

  • --detailed - Show detailed analysis statistics

sql#

Reconstruct SQL DDL from schema.

dbsurveyor sql <INPUT_FILE> [OPTIONS]

Options:

  • --dialect <DIALECT> - Target SQL dialect (default: postgresql)
  • --output <PATH> - Output file path

SQL Dialects:

  • postgresql - PostgreSQL dialect (🚧 Placeholder)
  • mysql - MySQL dialect (🚧 Placeholder)
  • sqlite - SQLite dialect (🚧 Placeholder)
  • sqlserver - SQL Server dialect (🚧 Placeholder)
  • generic - Generic SQL (ANSI standard) (🚧 Placeholder)

validate#

Validate schema file format.

dbsurveyor validate <INPUT_FILE>

Examples#

# Generate Markdown documentation
dbsurveyor generate schema.dbsurveyor.json

# Generate HTML report
dbsurveyor --format html --output report.html schema.json

# Process encrypted schema (will prompt for password)
dbsurveyor generate schema.enc

# Generate SQL DDL for MySQL
dbsurveyor sql schema.json --dialect mysql --output recreate.sql

# Analyze schema with detailed statistics
dbsurveyor analyze schema.json --detailed

# Validate schema file format
dbsurveyor validate schema.dbsurveyor.json

# Generate with conservative redaction
dbsurveyor --redact-mode conservative schema.json

# Generate without any redaction
dbsurveyor --no-redact schema.json

Input File Formats#

DBSurveyor automatically detects input file formats:

ExtensionFormatDescription
.jsonJSONStandard schema format
.zstCompressedZstandard compressed JSON
.encEncryptedAES-GCM encrypted JSON

Exit Codes#

CodeDescription
0Success
1General error

Note: Both binaries currently use exit code 1 for all error conditions. Granular exit codes (e.g., file-not-found, connection failure) may be added in a future release.

Environment Variables#

VariableDescription
RUST_LOGLogging configuration
NO_COLORDisable colored output
DBSURVEYOR_MAX_CONNECTIONSMaximum connection pool size (default: 10)
DBSURVEYOR_MIN_IDLE_CONNECTIONSMinimum idle connections in pool (default: 2)
DBSURVEYOR_CONNECT_TIMEOUT_SECSConnection timeout in seconds (default: 30)
DBSURVEYOR_IDLE_TIMEOUT_SECSIdle connection timeout in seconds (default: 600)
DBSURVEYOR_MAX_LIFETIME_SECSMaximum connection lifetime in seconds (default: 3600)

Common Usage Patterns#

Secure Workflow#

# 1. Test connection
dbsurveyor-collect test postgres://user:pass@localhost/db

# 2. Collect with encryption
dbsurveyor-collect --encrypt postgres://user:pass@localhost/db

# 3. Generate documentation offline
dbsurveyor generate schema.enc

# 4. Validate output
dbsurveyor validate schema.enc

Multi-Database Documentation#

# Collect from multiple databases
dbsurveyor-collect --all-databases postgres://localhost > collection.log

# Generate comprehensive report
dbsurveyor --format html --output full-report.html schema.dbsurveyor.json

# Extract SQL for specific database
dbsurveyor sql schema.json --dialect postgresql --output postgres-ddl.sql

Development Workflow#

# Quick collection and documentation
dbsurveyor-collect sqlite://dev.db && dbsurveyor generate schema.dbsurveyor.json

# Analyze changes
dbsurveyor analyze schema.dbsurveyor.json --detailed

# Generate multiple formats
for format in markdown html mermaid; do
    dbsurveyor --format $format schema.dbsurveyor.json
done