On 28/10/2014 9:31 PM, John McKown wrote:
I've got a new build for Lua4z which includes sqlite3 as part of LuaSQL
>https://github.com/keplerproject/luasql. I'm going to release it soon
>with the regex extensions for POSIX and PCRE.
>
>
​Wonderful. Thanks. I will now just wait. I'm__good__ at just waiting.
I've uploaded a new build with sqlite3. You will have to install the
whole package again (we don't have a package installaer)
Test case:
-- load driver
luasql = require "luasql.sqlite3"
-- create environment object
env = assert (luasql.sqlite3())
-- connect to data source
con = assert (env:connect("luasql-test"))
-- reset our table
res = con:execute"DROP TABLE people"
res = assert (con:execute[[
CREATE TABLE people(
name varchar(50),
email varchar(50)
)
]])
-- add a few elements
list = {
{ name="Jose das Couves", email="[email protected]", },
{ name="Manoel Joaquim", email="[email protected]", },
{ name="Maria das Dores", email="[email protected]", },
}
con:setautocommit(false)
for i = 1, 10 do
for _, p in pairs (list) do
res = assert (con:execute(string.format([[
INSERT INTO people
VALUES ('%s', '%s')]], p.name .. i, p.email..i)
))
end
end
con:commit()
-- retrieve a cursor
cur = assert (con:execute"SELECT name, email from people")
-- print all rows, the rows will be indexed by field names
row = cur:fetch ({}, "a")
while row do
print(string.format("Name: %s, E-mail: %s", row.name, row.email))
-- reusing the table of results
row = cur:fetch (row, "a")
end
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN