On Thu, Sep 30, 2010 at 6:19 PM, Petite Abeille <petite.abei...@gmail.com>wrote:

> Hello,
>
> [Mac OS X 10.6.4, SQLite 3.7.2, Lua 5.2.0, LuaSQL $Id: ls_sqlite3.c,v 1.15
> 2009/02/07 23:16:23 $]
>
> How does one fetch from a pragma such as pragma database_list or
> table_info?
>
>
At least with SQLite 3.6.13, with LuaSQL, the following works. (conn is a
LuaSQL connection)

function GetTablePrimaryKey(conn, tableName)
local rows = {}
local index = 0
local sql = string.format([[PRAGMA table_info(%s)]], tableName)
local cursor, err = conn:execute(sql)
if not cursor then error(err) end
local row = cursor:fetch({}, "a")
while row and row.pk == 1 do
table.insert(rows, #rows, row.name)
row = cursor:fetch(row, "a")
end
cursor:close()
return rows
end


Never tried with database_list, though.
_______________________________________________
Kepler-Project mailing list
Kepler-Project@lists.luaforge.net
http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
http://www.keplerproject.org/

Reply via email to