Last active
May 24, 2024 19:54
-
-
Save henriquegogo/fa22ffec3eb345540ef2 to your computer and use it in GitHub Desktop.
LuaSQL-SQLite3 example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!./bin/lua | |
local driver = require('luasql.sqlite3') | |
local env = driver.sqlite3() | |
local db = env:connect('db.sqlite') | |
db:execute[[ | |
CREATE TABLE generic( | |
key varchar(50), | |
value varchar(150) | |
) | |
]] | |
db:execute[[ | |
INSERT INTO generic VALUES('nome', 'coisa') | |
]] | |
local results = db:execute[[ | |
SELECT * FROM generic | |
]] | |
local key,value = results:fetch() | |
while key do | |
print(key ..': '.. value) | |
key,value = results:fetch() | |
end | |
results:close() | |
db:close() | |
env:close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent, the only one that really worked