lua-users home
lua-l archive

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


Drake Wilson wrote:

> I can't speak for Lua-in-general, of course, but roughly speaking,
> I'd prefer something like:
>
>  Result set: integer keys -> rows;
>              string keys -> various metadata if needed.
>  Row: integer keys -> cell values in order (by column index);
>       string keys -> cell values by column name.

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.

  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?