title: Luasql and SQLite?
body: <p>I just got started looking at Lua as an easy way to access the SQLite DLL, but I ran into an error while trying to use the DB-agnostic LuaSQL module:</p>
  
  <pre><code>require "luasql.sqlite"
  module "luasql.sqlite"
  
  print("Content-type: Text/html\n")
  
  print("Hello!")
  </code></pre>
  
  <p>Note that I'm trying to start from the most basic setup, so only have the following files in the work directory, and sqlite.dll is actually the renamed sqlite3.dll from the <a href="http://luaforge.net/frs/?group_id=12" rel="noreferrer">LuaForge</a> site:</p>
  
  <pre>
  Directory of C:\Temp
  &lt;DIR&gt; luasql
  lua5.1.exe
  lua5.1.dll
  hello.lua
  
  Directory of C:\Temp\luasql
  sqlite.dll
  </pre>
  
  <p>Am I missing some binaries that would explain the error?</p>
  
  <p>Thank you.</p>
  
  <hr>
  
  <p>Edit: I renamed the DLL to its original sqlite3.dll and updated the source to reflect this (originally renamed it because that's how it was called in a sample I found).</p>
  
  <p>At this point, here's what the code looks like...</p>
  
  <pre><code>require "luasql.sqlite3"
  
  -- attempt to call field 'sqlite' (a nil value)
  env = luasql.sqlite()
  
  env:close()
  </code></pre>
  
  <p>...  and the error message I'm getting:</p>
  
  <pre><code>C:\&gt;lua5.1.exe hello.lua
  lua5.1.exe: hello.lua:4: attempt to call field 'sqlite' (a nil value)
  </code></pre>
  
  <hr>
  
  <p>Edit: Found what it was: env = luasql.sqlite3() instead of env = luasql.sqlite().</p>
  
  <p>For newbies like me, here's a complete example with the latest <a href="http://www.keplerproject.org/luasql/" rel="noreferrer">SQLite LuaSQL driver</a>:</p>
  
  <pre><code>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()
  </code></pre>
  
  <p>Thank you.</p>