mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-06-12 07:01:19 +00:00
Update the usage example
This commit is contained in:
24
src/lib.rs
24
src/lib.rs
@ -1,3 +1,27 @@
|
||||
//! Interface to [SQLite][1].
|
||||
//!
|
||||
//! ## Example
|
||||
//!
|
||||
//! ```
|
||||
//! use std::path::Path;
|
||||
//!
|
||||
//! let database = sqlite::open(&Path::new(":memory:")).unwrap();
|
||||
//!
|
||||
//! database.execute(r#"
|
||||
//! CREATE TABLE `users` (id INTEGER, name VARCHAR(255));
|
||||
//! INSERT INTO `users` (id, name) VALUES (1, 'Alice');
|
||||
//! "#).unwrap();
|
||||
//!
|
||||
//! database.process("SELECT * FROM `users`;", |pairs| {
|
||||
//! for &(column, value) in pairs.iter() {
|
||||
//! println!("{} = {}", column, value.unwrap());
|
||||
//! }
|
||||
//! true
|
||||
//! }).unwrap();
|
||||
//! ```
|
||||
//!
|
||||
//! [1]: https://www.sqlite.org
|
||||
|
||||
#![allow(unused_unsafe)]
|
||||
|
||||
extern crate libc;
|
||||
|
Reference in New Issue
Block a user