[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Result sets - what's the "Lua way"
- From: Petite Abeille <petite.abeille@...>
- Date: Thu, 5 May 2011 19:04:48 +0200
On May 4, 2011, at 6:39 PM, Henderson, Michael D wrote:
> I'm writing a SQL interface for Oracle and have a question on representing the result sets.
Someone else pointed it out already, but perhaps it's worthwhile repeating:
LuaSQL
http://www.keplerproject.org/luasql/
Also:
LuaDBI
http://code.google.com/p/luadbi/
Both support Oracle to various degree.
If you write your own Oracle interface, one would hope that you will provide a LuaSQL compatible API as a courtesy :)
As far as result set goes, here is the API I personally find convenient [1]:
local aDB = DB( 'sqlite3://localhost/test.db' )
for aContact in aDB( 'select * from contact' ) do
print( aContact.name, aContact.email )
end
FWIW, bellow is a more fullfledge example, with associated DML:
http://dev.alt.textdrive.com/browser/IMDB/Info.lua#L46
http://dev.alt.textdrive.com/browser/IMDB/Info.ddl#L357
[1] http://dev.alt.textdrive.com/browser/IMDB/DB.lua#L176