Anyone know how to use Lua to test if a table exists in a SQLite db?
Not the sql: CREATE TABLE IF NOT EXISTS
I want: if "table exists in database" then
Not the sql: CREATE TABLE IF NOT EXISTS
I want: if "table exists in database" then
This forum is a read-only archive of the Gammon Software forum (2000–2026). No new posts can be made. Search the archive.
Posted by Blainer on Tue 09 Jun 2009 03:27 PM — 4 posts, 22,944 views.
function Sqlitedb:checkfortable(tablename)
if self:open() then
for a in self.db:nrows('SELECT name FROM sqlite_master') do
if a['name'] == tablename then
self:close()
return true
end
end
self:close()
end
return false
end
SELECT * FROM sqlite_master WHERE name = 'whatever' AND type = 'table'