Expand description
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.!
Structs§
- Avro
Column - Table column represented as
AvroValue. - Avro
Configuration - ODBC to Avor record processing configuration and internal state.
- Avro
Configuration Builder - Helper object that allows to build
AvroConfigurationwith custom settings. - Avro
Name - Represents valid Avro name as defined by standard.
- Avro
RowRecord - Table row represented as
AvroValue::Record. - Name
Normalization Error - State
- Internal state used to cache row metadata.
- Writer
- Main interface for writing Avro formatted values.
Enums§
- Avro
Schema - Represents any valid Avro schema More information about Avro schemas can be found in the Avro Specification
- Avro
Value - Represents any valid Avro value More information about Avro values can be found in the Avro Specification
- Codec
- The compression codec used to compress blocks.
- Odbc
Avro Error - Errors that this library can produce.
- Reformat
Json - Specification of JSON column data is reformatted.
- Timestamp
Format - Specification of TIMESTAMP column representation.
Traits§
- Avro
Result Set - Extension functions for
ResultSet. - Avro
RowRecord Iter - Extension functions for iterators of
AvroRowRecorditems.