[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Luasql question and some other help
- From: Vijay <vijay@...>
- Date: Mon, 16 Apr 2012 21:08:39 -0400
Hi list,
Firstly, pardon me if my question is already answered. I've never
really used mailing lists much and I couldn't figure out how to
search for my answers. If someone could point me where to get started
that would be very helpful.
More specifically, I'm running into a problem with the following
script:
--[[
Lua version:
Lua 5.2.0 Copyright (C) 1994-2011 Lua.org, PUC-Rio
Compiled Luasql manually and installed .so in appropriate places
--]]
require "luasql.postgres"
db = "tst"
query = "select word, definition from dict_list where word like 'Ab%'"
-- env = assert(luasql.postgres()) -- <-- this raises error
-- env = assert(package.loaded["luasql.postgres"]()) -- <-- fails too!!
pg = package.loaded["luasql.postgres"]
env = assert(pg.postgres()) -- <-- works!! Why??
-- Have I done something wrong that I have to look into package.loaded
-- to figure this stuff out??
con = assert(env:connect(db))
cur = assert(con:execute(query))
row = cur:fetch({}, "a")
while row do
print(string.format("%s: %s", row.word, row.definition))
row = cur:fetch(row, "a")
end
cur:close()
con:close()
env:close()
----
Again, please pardon me if I'm not following the standard procedures...it's
because of my inexperience.
Thanks,
Vijay.