Skip to content
This repository has been archived by the owner on Sep 3, 2023. It is now read-only.

Commit

Permalink
Updated README. Added custom struct as row type example
Browse files Browse the repository at this point in the history
  • Loading branch information
bobozaur committed Apr 2, 2022
1 parent 353ea0c commit 6cc4a9d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 19 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Crates.io](https://img.shields.io/crates/v/exasol.svg)](https://crates.io/crates/exasol)

# exasol
A synchronous database connector for Exasol written in Rust, based on the Exasol [Websocket API](https://github.com/exasol/websocket-api).
Inspired by [Py-Exasol](https://github.com/exasol/pyexasol).
Expand Down
56 changes: 37 additions & 19 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@
//! against it (the same can be done for the `u32` representing the affected rows count).
//!
//! ```
//! # use exasol::error::Result;
//! # use exasol::{connect, bind, QueryResult, ResultSet};
//! # use std::env;
//! # use serde_json::Value;
//! #
//! # let dsn = env::var("EXA_DSN").unwrap();
//! # let schema = env::var("EXA_SCHEMA").unwrap();
//! # let user = env::var("EXA_USER").unwrap();
//! # let password = env::var("EXA_PASSWORD").unwrap();
//! #
//! use exasol::error::Result;
//! use exasol::{connect, bind, QueryResult, ResultSet};
//! use std::env;
//! use serde_json::Value;
//!
//! let dsn = env::var("EXA_DSN").unwrap();
//! let schema = env::var("EXA_SCHEMA").unwrap();
//! let user = env::var("EXA_USER").unwrap();
//! let password = env::var("EXA_PASSWORD").unwrap();
//!
//! let mut exa_con = connect(&dsn, &schema, &user, &password).unwrap();
//! let result = exa_con.execute("SELECT OBJECT_NAME FROM EXA_ALL_OBJECTS LIMIT 5000;").unwrap();
//!
Expand Down Expand Up @@ -92,15 +92,16 @@
//! For `enum` sequence-like variants, see [deserialize_as_seq].
//!
//! ```
//! # use exasol::{connect, QueryResult, ResultSet};
//! # use exasol::error::Result;
//! # use serde_json::Value;
//! # use std::env;
//! #
//! # let dsn = env::var("EXA_DSN").unwrap();
//! # let schema = env::var("EXA_SCHEMA").unwrap();
//! # let user = env::var("EXA_USER").unwrap();
//! # let password = env::var("EXA_PASSWORD").unwrap();
//! use exasol::{connect, QueryResult, ResultSet};
//! use exasol::error::Result;
//! use serde_json::Value;
//! use serde::Deserialize;
//! use std::env;
//!
//! let dsn = env::var("EXA_DSN").unwrap();
//! let schema = env::var("EXA_SCHEMA").unwrap();
//! let user = env::var("EXA_USER").unwrap();
//! let password = env::var("EXA_PASSWORD").unwrap();
//! let mut exa_con = connect(&dsn, &schema, &user, &password).unwrap();
//! let result = exa_con.execute("SELECT 1, 2 UNION ALL SELECT 1, 2;").unwrap();
//!
Expand All @@ -112,6 +113,23 @@
//! // on the same result set, even while iterating through it
//! let mut result_set = result_set.with_row_type::<Vec<String>>();
//! let row2 = result_set.next();
//!
//! let result = exa_con.execute("SELECT 1 as col1, 2 as col2, 3 as col3 \
//! UNION ALL \
//! SELECT 4 as col1, 5 as col2, 6 as col3;").unwrap();
//!
//! #[derive(Debug, Deserialize)]
//! struct Test {
//! col1: u8,
//! col2: u8,
//! col3: u8,
//! }
//!
//! let result_set = ResultSet::try_from(result).unwrap().with_row_type::<Test>();
//! for row in result_set.with_row_type::<Test>() {
//! let ok_row = row.unwrap();
//! // do stuff with row
//! }
//! ```
//!
//! # Parameter binding
Expand Down

0 comments on commit 6cc4a9d

Please sign in to comment.