Re: [sqlite] Accessing SQLite from Lua?

2010-05-05 Thread Gilles Ganault
On Wed, 05 May 2010 13:32:24 +0200, Gilles Ganault
 wrote:
>I'd like to know how to use this from a Lua script.

For Lua newbies like me who'd like to access an SQLite database
through the LuaSql interface, here's how to do it:

1. In the directory where the Lua interpreter is located, create a
sub-directory \luasql

2. In this sub-directory, from http://luaforge.net/frs/?group_id=12,
download and unzip luasql-2.1.1-sqlite3-win32-lua51.zip, which
contains sqlite3.dll (a Lua-specific sqlite3.dll, not the one from
www.sqlite.org)

3. In the main directory, create a source file eg. test.lua:

--
require "luasql.sqlite3"

env = luasql.sqlite3()
conn = env:connect("test.sqlite")

assert(conn:execute("create table if not exists tbl1(one varchar(10),
two smallint)"))
assert(conn:execute("insert into tbl1 values('hello!',10)"))
assert(conn:execute("insert into tbl1 values('goodbye',20)"))

cursor = assert(conn:execute("select * from tbl1"))
row = {}
while cursor:fetch(row) do
print(table.concat(row, '|'))
end

cursor:close()
conn:close()

env:close()
--

4. Launch this script:
lua5.1.exe test.lua

HTH,

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Accessing SQLite from Lua?

2010-05-05 Thread Gilles Ganault
Hello

>From what I've been reading this morning, it appears that Lua offers
two ways to access an SQLite database:
- through the database-neutral Lua API LuaSQL
- by calling the SQLite-specific luasqlite

I have no preference, and would like to find the Windows binaries
that I could just copy to the directory where the Lua interpreter is
located and access SQLite through eg. "require("luasql.sqlite")".

The only SQLite file in the "Lua for Windows" package is this:
"C:\Program Files\Lua\5.1\clibs\luasql\sqlite3.dll" 

I'd like to know how to use this from a Lua script.

Thank you.

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users