arcapos / luapgsql

Lua binding for PostgreSQL
108 stars 24 forks source link

Fetch query result as associative array? #54

Closed d9k closed 3 years ago

d9k commented 5 years ago

Is it possible to present query result row as associative array, where key is column name and value is column value for current row?

see http://php.net/manual/en/function.pg-fetch-assoc.php and http://norman.github.io/lua-postgres/modules/postgres.result.html#fetch_assoc

daurnimator commented 5 years ago

tuple:copy() does this. It's not documented though.

https://github.com/arcapos/luapgsql/blob/2381c9d5dc47c38db642fbfcd6c1d0216f20b8a9/luapgsql.c#L1906-L1910

d9k commented 5 years ago

@daurnimator, thanks! @mbalmer, please improve the docs regarding this method.

mbalmer commented 3 years ago

Keep an eye on https://lua.msys.ch/lua-module-reference.html#pgsql, I will add the tuple:copy() function there. Probably in a section "Lua specific functions".