#odbc #orm #avro

odbc-avro

Extends odbc-iter crate functionality with ability to query Avro records and write entire ResultSet as Avro Object Container File data

4 releases

0.2.1 Jan 23, 2020
0.2.0 Aug 28, 2019
0.1.1 Aug 27, 2019
0.1.0 Aug 16, 2019

#2164 in Database interfaces

Download history 15/week @ 2023-10-31 9/week @ 2023-11-07 13/week @ 2023-11-14 17/week @ 2023-11-21 23/week @ 2023-11-28 10/week @ 2023-12-05 10/week @ 2023-12-12 13/week @ 2023-12-19 15/week @ 2023-12-26 9/week @ 2024-01-02 11/week @ 2024-01-09 8/week @ 2024-01-16 8/week @ 2024-01-23 14/week @ 2024-01-30 10/week @ 2024-02-06 38/week @ 2024-02-13

72 downloads per month
Used in odbc-tools

MIT license

40KB
724 lines

Latest Version Documentation License

This Rust crate extends odbc-iter crate functionality with ability to query Avro records and write entire ResultSet as Avro "Object Container File" data.

Example usage

Write Avro object container file data from query.

use odbc_iter::Odbc;
use odbc_avro::{AvroConfiguration, AvroResultSet, Codec};

let mut connection = Odbc::connect(&std::env::var("DB_CONNECTION_STRING").expect("no DB_CONNECTION_STRING env set")).expect("connect to database");

// Configure handler with default `AvroConfiguration`.
let mut db = connection.handle_with_configuration(AvroConfiguration::default());

// For example query all table data from database.
let data = db.query(r#"SELECT * FROM sys.tables"#).expect("query failed");

// You can use `File` instead to write Avro object container file or any other `Write` type.
let mut buf = Vec::new();

// Write all rows as uncompressed Avro object container file where rows are represented as record object named "result_set".
data.write_avro(&mut buf, Codec::Null, "result_set").expect("write worked");

// Now `buf` contains all rows from `sys.tables` table serialized Avro object container file.

Dependencies

~5.5–8MB
~146K SLoC