Purpose
Run SQL files against MSSQL and export results to CSV, optionally through an SSH tunnel.
Current state
Last touched: 2025-04-25. Functionality and completeness: Core export flow is implemented; documentation and tests 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- TOML config, SQL file, MSSQL database
- Configuration files (TOML)
- SQL query file
Outputs- CSV output file
- Query results (reports/extracts)
- CSV files
Reality to Action trace
Reality IngestionNot in scope.
Canonical StorageContributes in this stage.
Automation EnginesNot in scope.
Human InterfacesNot in scope.
Operational AdoptionNot in scope.
Core workflow
TBD. Document the 5-10 steps that define the core workflow.
Artifacts
- CSV column headers derive from query result columns
Operational notes
Constraints and scars
- Requires direct DB connectivity or SSH tunnel; no built-in retry/transaction controls.
Reliability posture
Failure modes and safe behavior: SSH or DB connection failures abort run; partial CSV may be written if failure occurs mid-stream. Idempotency / retries / batching behavior: Re-running overwrites output file; no automatic retries.
Observability
- Logs: Rust logging framework detected (log/tracing/env_logger).
- Metrics/health checks: None documented
- Logs: tracing logs to stdout (connection, execution, export, SSH tunnel lifecycle).
Security and privacy
Config contains DB and SSH credentials; secure storage and file permissions are required.
Dependencies
Upstream- Microsoft SQL Server
- optional SSH tunnel via local `ssh` binary
Ownership
OwnersJosh Barton
UsersJosh Barton (owner)
mssql_to_csv
Architecture & Major Components
High-level diagram (text):
- Entry/trigger -> core logic -> outputs (details per docs below)
Entry/trigger
→core logic
→outputs
Entry points: src/main.rs
Top-level folders: src
Key abstractions: Config parsing, optional SSH tunnel bootstrap, query execution, CSV writer with delimiter/quote options
Setup / Build / Run
- Build system(s): Cargo.
- Provide a
config.toml with database and query paths; run the CLI for exports.