use faucet_stream::Pipeline;
use faucet_stream::sink::sqlite::{SqliteColumnMapping, SqliteSink, SqliteSinkConfig};
use faucet_stream::source::csv::{CsvSource, CsvSourceConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let source = CsvSource::new(
CsvSourceConfig::new("inventory.tsv")
.has_headers(false)
.delimiter(b'\t')
.quote(b'\''),
);
let sink = SqliteSink::new(
SqliteSinkConfig::new("sqlite:./inventory.db", "inventory")
.column_mapping(SqliteColumnMapping::Json {
column: "row".into(),
})
.with_batch_size(500)
.max_connections(4),
)
.await?;
let result = Pipeline::new(&source, &sink).run().await?;
println!(
"imported {} inventory rows into SQLite",
result.records_written
);
Ok(())
}