File: smart.lua

package info (click to toggle)
lua-lsqlite3 0.9.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,208 kB
  • sloc: ansic: 134,891; makefile: 84
file content (22 lines) | stat: -rw-r--r-- 529 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

local sqlite3 = require("lsqlite3")

local db = sqlite3.open_memory()

db:exec[[ CREATE TABLE test (id INTEGER PRIMARY KEY, content) ]]

local stmt = db:prepare[[ INSERT INTO test VALUES (:key, :value) ]]

stmt:bind_names{  key = 1,  value = "Hello World"    }
stmt:step()
stmt:reset()
stmt:bind_names{  key = 2,  value = "Hello Lua"      }
stmt:step()
stmt:reset()
stmt:bind_names{  key = 3,  value = "Hello Sqlite3"  }
stmt:step()
stmt:finalize()

for row in db:nrows("SELECT * FROM test") do
  print(row.id, row.content)
end