lua-users home
lua-l archive

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


	Hi Michael

Can you show how you'd like the code to look? That's what I'm trying to work out. I can code behind it but I'm not sure on how it should look.
    Take a look at LuaSQL (http://www.keplerproject.org/luasql/).  It has
a very simple API over which it is not difficult to write a higher level
one such as Dado (http://www.ccpa.puc-rio.br/software/dado/).

 result, err = sql.exec("select min(wage) as minwage, max(wage) as maxwage from employee")
 print(result.rowCount)
 print("minimum wage is ", result[1].minwage)
 print("maximum wage is ", result[1].maxwage)

or

 result, err = sql.exec("select id, name, wage from employee order by name")
 for id,name,wage in pairs(result)
    print(id, name, wage)
 end

or

 minwage, maxwage, err = sql.exec("select min(wage) as minwage, max(wage) as maxwage from employee")
 print("minimum wage is ", minwage)
 print("maximum wage is ", maxwage)

Sorry if I'm being vague but what I'm trying to get at is as a developer, what would you want the API to look like? What would your side of the code look like?
	I am very used to the above APIs thus my opinion could be biased :-)
	I think that an API that gives you a table with the whole result
set is very flexible, but for a large amount of data, this could consume
too much memory unnecessarily.	An alternative for that is to return a
proxy that retrieves data on demand, but it also has some disadvantages.
	Another polemical decision is whether convert the data to native Lua types or not.  LuaSQL does not define anything, thus the drivers behave differently which could be annoying for some people.

	Regards,
		Tomás