Last active
December 16, 2015 17:28
-
-
Save grahamking/5470148 to your computer and use it in GitHub Desktop.
Rust: Use sqlite
This file contains 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; | |
fn db() { | |
let database = | |
match sqlite::open("test.db") { | |
Ok(db) => db, | |
Err(e) => { | |
println(fmt!("Error opening test.db: %?", e)); | |
return; | |
} | |
}; | |
let mut result = database.exec("CREATE TABLE test (name text, age int)"); | |
println(fmt!("Create OK? %?", result.is_ok())); | |
result = database.exec("INSERT INTO test VALUES ('Graham', 36)"); | |
println(fmt!("Insert OK? %?", result.is_ok())); | |
} | |
fn main() { | |
db(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
extern mod sqlite;
fn db() {
}
fn main() {
db();
}