#rdbc #postgresql #driver #connectivity #query #api

rbatis_drivers

Rust DataBase Connectivity (RDBC) API

3 stable releases

1.0.2 Apr 11, 2020
1.0.1 Feb 16, 2020
1.0.0 Feb 15, 2020

#13 in #rdbc

MIT license

23KB
516 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, MySQL and SQLite.

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

use crate::*;
use rdbc_postgres::PostgresDriver;

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

Dependencies

~19–31MB
~518K SLoC