Created
November 7, 2013 22:35
-
-
Save brinchj/7363049 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern mod sqlite; | |
use sqlite::types::SQLITE_OK; | |
fn open_db(path: ~str) -> sqlite::database::Database { | |
match sqlite::open(path) { | |
Ok(db) => db, | |
Err(r) => fail!(r) | |
} | |
} | |
fn test() { | |
let mut db = open_db(~":memory:"); | |
// Create table | |
let result = db.exec("CREATE TABLE IF NOT EXISTS test (name text)"); | |
println(format!("Create OK? {:b}", result.is_ok())); | |
// Prepared insert | |
let mut stmt = match db.prepare("INSERT INTO test (name) VALUES (?)", &None) { | |
Ok(s) => s, | |
Err(err) => fail!(err) | |
}; | |
assert!(stmt.bind_param(1, &sqlite::types::Text(~"test")) == SQLITE_OK); | |
} | |
fn main() { | |
test() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment