7 releases

0.1.6 Dec 23, 2019
0.1.5 Dec 23, 2019

#13 in #connectivity


Used in 4 crates

Apache-2.0

6KB
90 lines

The RDBC (Rust DataBase Connectivity) API is loosely based on the ODBC and JDBC standards and provides a database agnostic programming interface for executing queries and fetching results.

Reference implementation RDBC Drivers exist for Postgres and MySQL.

The following example demonstrates how RDBC can be used to run a trivial query against Postgres.

use rdbc::Value;
use rdbc_postgres::PostgresDriver;
let driver = PostgresDriver::new();
let conn = driver.connect("postgres://postgres:password@localhost:5433").unwrap();
let mut conn = conn.borrow_mut();
let stmt = conn.prepare("SELECT a FROM b WHERE c = ?").unwrap();
let mut stmt = stmt.borrow_mut();
let rs = stmt.execute_query(&vec![Value::Int32(123)]).unwrap();
let mut rs = rs.borrow_mut();
while rs.next() {
  println!("{:?}", rs.get_string(1));
}

No runtime deps