mirror of
https://github.com/Egor00f/luasqlite3-kolibrios.git
synced 2025-09-11 14:39:57 +02:00
upload luasqlite3
This commit is contained in:
22
examples/smart.lua
Normal file
22
examples/smart.lua
Normal file
@@ -0,0 +1,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
|
Reference in New Issue
Block a user