Atlas project production

sql_to_csv

DB Query to CSV** is a flexible command-line tool written in Rust that connects to SQL databases (such as MSSQL, PostgreSQL, or MySQL) using SQLx, executes a user-defined SQL query, and exports the results to a CSV file. The program supports both configuration files (TOML format) and command-line overrides, making it adaptable for various environments and use cases. Run the tool with a config file or CLI overrides; CLI flags override config values.

Type
Field Tool
Lifecycle
Maintenance
Last touched
2025-04-25
Visibility
Public

Purpose

DB Query to CSV** is a flexible command-line tool written in Rust that connects to SQL databases (such as MSSQL, PostgreSQL, or MySQL) using SQLx, executes a user-defined SQL query, and exports the results to a CSV file. The program supports both configuration files (TOML format) and command-line overrides, making it adaptable for various environments and use cases.

Current state

Last touched: 2025-04-25. Functionality and completeness: Core multi-DB export is implemented; tests and CI are pending.

Next step

Add baseline automated tests to cover critical flows; Add CI pipeline for build/test/lint; Document deployment/runtime environment (or add Dockerfile); Document interfaces (CLI flags, API endpoints, file formats); Add structured logging and basic health checks.

Interfaces

Inputs
  • config.toml (connection_string, query_file, output_file), SQL database
  • Configuration files (TOML)
  • SQL query file
Outputs
  • CSV output file
  • Query results (reports/extracts)
  • CSV files

Reality to Action trace

Reality Ingestion

Contributes in this stage.

Canonical Storage

Contributes in this stage.

Automation Engines

Not in scope.

Human Interfaces

Contributes in this stage.

Operational Adoption

Contributes in this stage.

Core workflow

TBD. Document the 5-10 steps that define the core workflow.

Operational notes

Constraints and scars

  • Relies on SQLx AnyPool; unsupported column types are coerced to strings where needed.

Reliability posture

Failure modes and safe behavior: Connection or query errors abort without writing a complete CSV. Idempotency / retries / batching behavior: Re-running overwrites output file; no built-in retries.

Observability

  • Logs: Rust logging framework detected (log/tracing/env_logger).
  • Metrics/health checks: None documented
  • Logs: stdout/stderr via Rust logging; no explicit metrics documented.

Security and privacy

Connection strings often include credentials; keep configs out of git and avoid shell history leaks.

Dependencies

Upstream
  • SQL databases via SQLx (MSSQL, Postgres, MySQL)

Ownership

Owners

Josh Barton

Users

Josh Barton (owner)

sql_to_csv

Architecture & Major Components

  • High-level diagram (text):

    • Entry/trigger -> core logic -> outputs (details per docs below)
  • Entry points: src/main.rs

  • Top-level folders: src

  • Key abstractions: SQLx AnyPool, config/CLI override merge, CSV writer

Setup / Build / Run

  • Build system(s): Cargo.
  • Install Rust, build with Cargo, and provide a config.toml (or CLI flags) with connection string and query file.
  • Ensure the target database is accessible and SQLx drivers are enabled via Cargo features.