Rust-oracle - Work in progress
This is an Oracle driver for Rust based on ODPI-C.
It is under development. Public API may be changed for each commit.
Build-time Requirements
- Rust 1.18 or later
- C compiler. See
Compile-time Requirements
in this document.
Run-time Requirements
- Oracle Client 11.2 or later. See ODPI-C installation document.
Usage
Rust-oracle has not been published to crates.io. You need to put this in your Cargo.toml:
[dependencies]
oracle = { git = "https://github.com/kubo/rust-oracle.git" }
Conversion from Oracle types to Rust types
Values in Oracle are converted to Rust type as possible as it can. The following table indicates supported conversion.
Oracle Type | Rust Type |
---|---|
CHAR, NCHAR, VARCHAR2, NVARCHAR2 | String |
″ | i8, i16, i32, i64, u8, u16, u32, u64 via parse() |
... | ... |
This conversion is used also to get values from output parameters.
Conversion from Rust types to Oracle types
When a rust value is set to an input parameter, its Oracle type is determined by the rust type.
Rust Type | Oracle Type |
---|---|
str, String | NVARCHAR2(length of the rust value) |
str, String via bind_value(value, length) |
NVARCHAR2(length passed to bind_value() ) |
str, String via bind_value(value, AS_LONG) |
LONG |
str, String via bind_value(value, AS_CLOB) |
CLOB |
str, String via bind_value(value, AS_NCLOB) |
NCLOB |
i8, i16, i32, i64, u8, u16, u32, u64, f32, f64 | NUMBER |
i8, i16, i32, i64, u8, u16, u32, u64, f32, f64 via bind_value(&value, AS_BINARY_DOUBLE) |
BINARY_DOUBLE |
Vec<u8> | RAW(length of the rust value) |
Vec<u8> via bind_value(value, length) |
RAW(length passed to bind_value() ) |
Vec<u8> via bind_value(value, AS_LONG_RAW) |
LONG RAW |
Vec<u8> via bind_value(value, AS_BLOB) |
BLOB |
chrono::DateTime, Timestamp | TIMESTAMP(9) WITH TIME ZONE |
chrono::Date | TIMESTAMP(0) WITH TIME ZONE |
chrono::naive::NaiveDateTime | TIMESTAMP(9) |
chrono::naive::NaiveDate | TIMESTAMP(0) |
chrono::Duration, IntervalDS | INTERVAL DAY(9) TO SECOND(9) |
IntervalYM | INTERVAL YEAR(9) TO MONTH |
TODO
- Connection pooling
- Read and write LOB as stream
- REF CURSOR, BOOLEAN, OBJECT types
- Autocommit mode
- Scrollable cursors
License
Rust-oracle itself is under 2-clause BSD-style license.
ODPI-C bundled in rust-oracle is under the terms of: