3 releases
0.1.6 | Dec 23, 2019 |
---|---|
0.1.5 | Dec 23, 2019 |
0.1.3 | Dec 22, 2019 |
#2 in #rdbc
Used in rdbc-cli
9KB
192 lines
SQLite RDBC Driver
This crate implements an RDBC Driver for the rusqlite
crate.
The RDBC (Rust DataBase Connectivity) API is loosely based on the ODBC and JDBC standards.
use std::sync::Arc;
use rdbc::{self, Value};
use rdbc_sqlite::SqliteDriver;
let driver: Arc<dyn rdbc::Driver> = Arc::new(SqliteDriver::new());
let conn = driver.connect("").unwrap();
let mut conn = conn.borrow_mut();
let stmt = conn.prepare("CREATE TABLE test (a INT NOT NULL)").unwrap().borrow_mut().execute_update(&vec![]).unwrap();
let stmt = conn.prepare("INSERT INTO test (a) VALUES (?)").unwrap().borrow_mut().execute_update(&vec![rdbc::Value::Int32(123)]).unwrap();
let stmt = conn.prepare("SELECT a FROM test").unwrap();
let mut stmt = stmt.borrow_mut();
let rs = stmt.execute_query(&vec![]).unwrap();
assert!(rs.as_ref().borrow_mut().next());
assert_eq!(Some(123), rs.as_ref().borrow_mut().get_i32(0).unwrap());
Dependencies
~22MB
~417K SLoC