diff options
| author | wires <wires@noreply.wires.systems> | 2025-10-24 11:29:46 -0400 |
|---|---|---|
| committer | wires <wires@noreply.wires.systems> | 2025-10-24 11:29:46 -0400 |
| commit | 92e4cfc123a1d26265128634850a2b73bac761c2 (patch) | |
| tree | bdbab6c9ac4a8e981888700e16a7e79b1afb3b27 /src/main.rs | |
| parent | initial commit (diff) | |
| download | wyrd-main.tar.gz | |
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 5b2e5a6..279e701 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,31 @@ -fn main() { - println!("hello, world!"); +use wyrd_sqlite::Connection; + +fn main() -> anyhow::Result<()> { + let conn = Connection::open("")?; + + conn.execute( + "CREATE TABLE pairs ( + a INTEGER PRIMARY KEY, + b INTEGER + )", + (), + )?; + + let (mut insert, _) = conn.prepare("INSERT INTO pairs (a, b) VALUES (?, ?)")?; + + insert.execute((23, ()))?; + insert.execute((3, 33))?; + insert.execute(((), 5))?; + + let (mut stmt, _) = conn.prepare("SELECT * FROM pairs")?; + let mut query = stmt.query(())?; + + while let Some(mut row) = query.try_next_row()? { + let a: i32 = { row.get(0)? }; + let b: Option<i32> = { row.get(1)? }; + + println!("{a}, {b:?}"); + } + + Ok(()) } |