Expand description
Sibyl is an OCI-based interface between Rust applications and Oracle databases. Sibyl supports both sync (blocking) and async (nonblocking) API.
Blocking Mode Example
fn main() -> sibyl::Result<()> {
let oracle = sibyl::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 c.country_name, Median(e.salary)
FROM hr.employees e
JOIN hr.departments d ON d.department_id = e.department_id
JOIN hr.locations l ON l.location_id = d.location_id
JOIN hr.countries c ON c.country_id = l.country_id
JOIN hr.regions r ON r.region_id = c.region_id
WHERE r.region_name = :REGION_NAME
GROUP BY c.country_name
")?;
let rows = stmt.query("Europe")?;
while let Some(row) = rows.next()? {
let country_name : &str = row.get(0)?;
let median_salary : u16 = row.get(1)?;
println!("{:25}: {:>5}", country_name, median_salary);
}
Ok(())
}
Nonblocking Mode Example
fn main() -> sibyl::Result<()> {
block_on(async {
let oracle = sibyl::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 c.country_name, Median(e.salary)
FROM hr.employees e
JOIN hr.departments d ON d.department_id = e.department_id
JOIN hr.locations l ON l.location_id = d.location_id
JOIN hr.countries c ON c.country_id = l.country_id
JOIN hr.regions r ON r.region_id = c.region_id
WHERE r.region_name = :REGION_NAME
GROUP BY c.country_name
").await?;
let rows = stmt.query("Europe").await?;
while let Some(row) = rows.next().await? {
let country_name : &str = row.get(0)?;
let median_salary : u16 = row.get(1)?;
println!("{:25}: {:>5}", country_name, median_salary);
}
Ok(())
})
}
Note that
block_on
in the example is an internal abstraction overblock_on
of different async executors. It is intended only to help running Sibyl’s own tests and examples.
Features
Sibyl has 2 main features - blocking
and nonblocking
. They are exclusive and one must be explicitly selected as neither is the default.
Sibyl compiled with a nonblocking
feature needs to integrate with the async executor that the application uses. At the moment Sybil supports
Tokio, Actix, async-std, and async-global-executor. One (and only one) of those must be selected together with a nonblocking
feature:
Feature | async Runtime |
---|---|
tokio | Tokio |
actix | Actix |
async-std | async-std |
async-global | async-global-executor |
Thus, for example, when Sibyl is used as a dependency, it might be included as:
[dependencies]
sibyl = { version = "0.6", features = ["blocking"] }
Or, when Sibyl is used in nonblocking mode as:
[dependencies]
sibyl = { version = "0.6", features = ["nonblocking", "tokio"] }
Structs
blocking
REF CURSOR
s or implicit results (from DBMS_SQL.RETURN_RESULT
) of an executed PL/SQL statement.Enums
Statics
nonblocking
Traits
Functions
Type Definitions
INTERVAL DAY TO SECOND
data type. It stores a period of time in terms of days, hours, minutes, and seconds.INTERVAL YEAR TO MONTH
data type. It stores a period of time in terms of years and months.Result
type for Sibyl.TIMESTAMP
data type. It stores year, month, day, hour, minute, second and fractional seconds.TIMESTAMP WITH LOCAL TIME ZONE
data type. It’s a variant of TIMESTAMP
that is normalized to the database time zone.TIMESTAMP WITH TIME ZONE
data type. It’s a variant of TIMESTAMP
that includes of a time zone region name or time zone offset in its value.