A tiny diesel add-on for streaming large tables. It currently allows streaming large serial tables using a cursor-based streaming strategy.
For a regular synchronous runtime:
toml
[dependencies]
diesel-streamer = { version = "0.1.10", features = ["sync"]}
For tokio async runtime:
toml
[dependencies]
diesel-streamer = { version = "0.1.10", features = ["async"]}
Stream SomeTable
that has a serial_field
:
```rust use dieselstreamer::streamserial_table;
fn main() { use crate::schema::sometable::dsl::{sometable, serial_field};
let mut conn = pool.get().await.unwrap();
// with default chunk size of 500
streamserialtable!(sometable, serialfield, conn, |streamedtabledata: Vec
// specify chunk size, 130
streamserialtable!(sometable, serialfield, conn, 130, |streamedtabledata: Vec
// with cursor's beginning, 5.
streamserialtable!(sometable, serialfield, conn, 130, 5, |streamedtabledata: Vec
// with cursor's end, 50,
streamserialtable!(sometable, serialfield, conn, 130, 5, 50, |streamedtabledata: Vec
Defaults:
serial_field
in the tableserial_field
in the tableN/B: Generally, streaming should only be considered when there is a possibility of hitting OOM error when processing the table in question.
Spin up a test db using docker-compose up
or simply specify
a DB url in .env
as shown in .env.sample
.
Run cargo test
for tests.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.