Expand description
DuckDB query engine for SQL dump analytics.
This module provides the ability to load SQL dumps into an embedded DuckDB database and execute analytical queries on them.
§Features
- Zero dependencies: DuckDB is bundled and compiled into sql-splitter
- Multi-dialect support: MySQL, PostgreSQL, and SQLite dumps
- Memory management: Auto-switches to disk mode for large dumps
- Caching: Optional persistent cache for repeated queries
§Example
ⓘ
use sql_splitter::duckdb::{QueryEngine, QueryConfig, QueryResultFormatter, OutputFormat};
use std::path::Path;
let config = QueryConfig::default();
let mut engine = QueryEngine::new(&config).unwrap();
engine.import_dump(Path::new("dump.sql")).unwrap();
let result = engine.query("SELECT COUNT(*) FROM users").unwrap();
println!("{}", QueryResultFormatter::format(&result, OutputFormat::Table));Structs§
- Batch
Manager - Manages batched INSERT operations for multiple tables
- Cache
Manager - Manager for cached DuckDB databases
- Dump
Loader - Loads SQL dumps into a DuckDB database
- Import
Stats - Statistics from dump import
- Insert
Batch - A batch of rows for a single table
- Query
Config - Configuration for the query engine
- Query
Engine - The main query engine that wraps DuckDB
- Query
Result - Result of a query execution
- Query
Result Formatter - Formatter for query results
- Type
Converter - Converter for SQL types to DuckDB-compatible types
Enums§
- Output
Format - Output format for query results
Constants§
- DISK_
MODE_ THRESHOLD - Threshold for automatic disk mode (2 GB)
- MAX_
ROWS_ PER_ BATCH - Maximum rows to accumulate per batch before flushing
Functions§
- flush_
batch - Flush a batch using DuckDB’s Appender API with transactional fallback
- should_
use_ disk_ mode - Determine if disk mode should be used based on file size