wires

summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorwires <wires@noreply.wires.systems>2025-10-24 11:29:46 -0400
committerwires <wires@noreply.wires.systems>2025-10-24 11:29:46 -0400
commit92e4cfc123a1d26265128634850a2b73bac761c2 (patch)
treebdbab6c9ac4a8e981888700e16a7e79b1afb3b27 /src
parentinitial commit (diff)
downloadwyrd-92e4cfc123a1d26265128634850a2b73bac761c2.tar.gz
first draft of sqlite wrapper HEAD main
Diffstat (limited to '')
-rw-r--r--src/main.rs32
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(())
 }