hdbconnect

Crates.iohdbconnect
lib.rshdbconnect
version
sourcesrc
created_at2016-12-07 19:14:05.45404
updated_at2024-12-11 11:16:19.98814
descriptionA synchronous pure rust database driver for SAP HANA(TM)
homepage
repositoryhttps://github.com/emabee/rust-hdbconnect
max_upload_size
id7506
Cargo.toml error:TOML parse error at line 27, column 1 | 27 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(PSeitz)

documentation

https://docs.rs/hdbconnect/

README

hdbconnect

Latest version Documentation License unsafe forbidden

A synchronous pure rust SQL driver for SAP HANA(TM).

Use hdbconnect_async if you want an asynchronous driver for SAP HANA.

Usage

Add hdbconnect to the dependencies section in your project's Cargo.toml:

[dependencies]
hdbconnect = "0.30"

Assuming you have

  • a HANA accessible at port 39013 on host hxehost,
  • and you can log on to it as user HORST with password SeCrEt,

then a first simple test which sets up some table, inserts data and reads them back might look like this:

use hdbconnect::{Connection, HdbResult};

pub fn main() -> HdbResult<()> {
    let mut connection = Connection::new("hdbsql://HORST:SeCrEt@hxehost:39013")?;

    // Cleanup if necessary, and set up a test table
    connection.multiple_statements_ignore_err(vec![
        "drop table FOO_SQUARE"
    ]);
    connection.multiple_statements(vec![
        "create table FOO_SQUARE ( f1 INT primary key, f2 BIGINT)",
    ])?;

    // Insert some test data
    let mut insert_stmt = connection.prepare(
        "insert into FOO_SQUARE (f1, f2) values(?,?)"
    )?;

    for i in 0..100 {
        insert_stmt.add_batch(&(i, i * i))?;
    }
    insert_stmt.execute_batch()?;

    // Read the table data directly into a rust data structure
    let stmt = "select * from FOO_SQUARE order by f1 asc";
    let n_square: Vec<(i32, u64)> =
        connection.query(stmt)?.try_into()?;

    // Verify ...
    for (idx, (n, square)) in n_square.into_iter().enumerate() {
        assert_eq!(idx as i32, n);
        assert_eq!((idx * idx) as u64, square);
    }
    Ok(())
}

Documentation

The docs contain more code examples, especially in the description of module code_examples.

TLS

The TLS implementation is based on rustls.

rustls's flexibility to use non-default crypto providers is currently not (yet) exposed by hdbconnect. Nevertheless, the need of rustls to initialize crypto shines through. We thus recommend calling hdbconnect::initialize_crypto early in your main.

Features

r2d2_pool

Adds an implementation of a r2d2 database pool.

dist_tx

Adds support for distributed transactions, based on dist_tx.

Versions

See the change log.

Commit count: 435

cargo fmt