lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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