https://github.com/quietboil/sibyl
An OCI-based interface between Rust applications and Oracle databases.
https://github.com/quietboil/sibyl
database oracle rust sql
Last synced: 6 months ago
JSON representation
An OCI-based interface between Rust applications and Oracle databases.
- Host: GitHub
- URL: https://github.com/quietboil/sibyl
- Owner: quietboil
- License: mit
- Created: 2019-06-10T21:39:07.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-02-21T21:01:50.000Z (about 1 year ago)
- Last Synced: 2025-10-01T12:50:04.183Z (6 months ago)
- Topics: database, oracle, rust, sql
- Language: Rust
- Homepage: https://quietboil.github.io/sibyl
- Size: 2.03 MB
- Stars: 35
- Watchers: 5
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sibyl
Sibyl is an [OCI][1]-based interface between Rust applications and Oracle databases. Sibyl supports both blocking (threads) and nonblocking (async) API.
[](https://crates.io/crates/sibyl)
[](https://docs.rs/sibyl)

## Example
### Blocking Mode
```rust
use sibyl as oracle; // pun intended :)
fn main() -> Result<(),Box> {
let oracle = oracle::env()?;
let dbname = std::env::var("DBNAME").expect("database name");
let dbuser = std::env::var("DBUSER").expect("user name");
let dbpass = std::env::var("DBPASS").expect("password");
let session = oracle.connect(&dbname, &dbuser, &dbpass)?;
let stmt = session.prepare("
SELECT first_name, last_name, hire_date
FROM hr.employees
WHERE hire_date >= :hire_date
ORDER BY hire_date
")?;
let date = oracle::Date::from_string("January 1, 2005", "MONTH DD, YYYY", &session)?;
let rows = stmt.query(&date)?;
while let Some( row ) = rows.next()? {
let first_name : Option<&str> = row.get(0)?;
let last_name : &str = row.get(1)?;
let hire_date : oracle::Date = row.get(2)?;
let hire_date = hire_date.to_string("FMMonth DD, YYYY")?;
if let Some(first_name) = first_name {
println!("{}: {} {}", hire_date, first_name, last_name);
} else {
println!("{}: {}", hire_date, last_name);
}
}
if stmt.row_count()? == 0 {
println!("No one was hired after {}", date.to_string("FMMonth DD, YYYY")?);
}
Ok(())
}
```
### Nonblocking Mode
```rust
use sibyl as oracle;
#[tokio::main]
async fn main() -> Result<(),Box> {
let oracle = oracle::env()?;
let dbname = std::env::var("DBNAME").expect("database name");
let dbuser = std::env::var("DBUSER").expect("user name");
let dbpass = std::env::var("DBPASS").expect("password");
let session = oracle.connect(&dbname, &dbuser, &dbpass).await?;
let stmt = session.prepare("
SELECT first_name, last_name, hire_date
FROM hr.employees
WHERE hire_date >= :hire_date
ORDER BY hire_date
").await?;
let date = oracle::Date::from_string("January 1, 2005", "MONTH DD, YYYY", &oracle)?;
let rows = stmt.query(&date).await?;
while let Some( row ) = rows.next().await? {
let first_name : Option<&str> = row.get(0)?;
let last_name : &str = row.get(1)?;
let hire_date : oracle::Date = row.get(2)?;
let hire_date = hire_date.to_string("FMMonth DD, YYYY")?;
if let Some(first_name) = first_name {
println!("{}: {} {}", hire_date, first_name, last_name);
} else {
println!("{}: {}", hire_date, last_name);
}
}
if stmt.row_count()? == 0 {
println!("No one was hired after {}", date.to_string("FMMonth DD, YYYY")?);
}
Ok(())
}
```
> Note that:
> - The nonblocking mode example is almost a verbatim copy of the blocking mode example with `await`s added.
> - The async example uses and depends on [Tokio][2]
> - For the moment, Sibyl can use only Tokio, Actix, async-std or async-global-executor as an async executor.
# Documentation
- [User Guide](https://quietboil.github.io/sibyl)
- [API](https://docs.rs/sibyl)
[1]: https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/index.html
[2]: https://crates.io/crates/tokio