Skip to content

Commit

Permalink
wasi,demo: add creating a table
Browse files Browse the repository at this point in the history
  • Loading branch information
psarna committed Nov 26, 2023
1 parent 52bf745 commit 2677d4f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libsql-sqlite3/ext/libsql-wasi-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,21 @@ fn main() -> anyhow::Result<()> {

libsql_wasi_init.call(&mut store, ())?;
let db = open_func.call(&mut store, db_path)?;

let sql = malloc.call(&mut store, 64)?;
memory.write(&mut store, sql as usize, b"PRAGMA journal_mode=WAL;\0")?;
let rc = exec_func.call(&mut store, (db, sql))?;
free.call(&mut store, sql)?;

let sql = malloc.call(&mut store, 64)?;
memory.write(
&mut store,
sql as usize,
b"CREATE TABLE testme(id, v1, v2);\0",
)?;
rc = exec_func.call(&mut store, (db, sql))?;
free.call(&mut store, sql)?;

let _ = close_func.call(&mut store, db)?;
free.call(&mut store, db_path)?;

Expand Down

0 comments on commit 2677d4f

Please sign in to comment.