#sql #tsurugidb

tsubakuro-rust-core

core library to access Tsurugi for Rust

5 releases

0.2.0 May 15, 2025
0.2.0-beta.1 May 14, 2025
0.1.0 Mar 17, 2025
0.1.0-beta.2 Mar 13, 2025

#513 in Database interfaces

Download history 329/week @ 2025-03-12 24/week @ 2025-03-19 1/week @ 2025-04-09 7/week @ 2025-04-16 13/week @ 2025-05-07 271/week @ 2025-05-14

284 downloads per month

Apache-2.0

485KB
11K SLoC

tsubakuro-rust-core

tsubakuro-rust-core is the core library to access Tsurugi for Rust.

tsubakuro-rust-core is a port from Tsubakuro/Java, but it does not cover all functions.

Limitations

  • Tsurugi 1.3.0 or later.
  • Provide SQL service only.
  • Only TCP connection is available.

Crate features

Default feature include the following features.

  • with_bigdecimal - Enable decimal via bigdecimal.
  • with_rust_decimal - Enable decimal via rust_decimal.
  • with_chrono - Enable date/time via chrono.
  • with_time - Enable date/time via time.

Rust version requirements

The Minimum Supported Rust Version (MSRV) is currently Rust 1.75.0.

How to use

Add tsubakuro-rust-core as a dependency to your Cargo.toml file:

[dependencies]
tsubakuro-rust-core = "0.2.0"

Example

connect example

use std::time::Duration;
use log::warn;
use tsubakuro_rust_core::prelude::*;

async fn example() -> Result<(), TgError> {
    let endpoint = Endpoint::parse("tcp://localhost:12345")?;

    let mut connection_option = ConnectionOption::new();
    connection_option.set_endpoint(endpoint);
    connection_option.set_application_name("Tsubakuro/Rust example");
    connection_option.set_session_label("example session");
    connection_option.set_default_timeout(Duration::from_secs(10));

    // connect
    let session = Session::connect(&connection_option).await?;

    // make SqlClient
    let client: SqlClient = session.make_client();

    // execute SQL
    let result = example_transaction(&client).await;

    // session close
    if let Err(e) = session.close().await {
        warn!("session close error. {}", e);
    }

    result
}

See example.rs for more examples.

How to build

Need protoc command since used prost.
(For example, to install protoc on Ubuntu 22.04, execute apt install protobuf-compiler)

If proto files in tsubakuro-proto has been modified, copy from there.

cd tsubakuro-rust-core
cp -rp /path/to/tsubakuro/modules/proto/src/main/protos .

Then build with cargo.

cd tsubakuro-rust-core
cargo build

How to test

cd tsubakuro-rust-core
cargo test

See also tsubakuro-rust-dbtest.

License

Apache License, Version 2.0

Dependencies

~5–16MB
~188K SLoC