views:

45

answers:

1

I'm using Luasqlite.

If I wanted to write a test to verify that a table exists, that returns boolean, how would I go about doing it?

It seems if I try selecting something from a table that doesn't exist, as my test, then the application errors out altogether.

Thank you!

A: 

You can execute the 'table_info' pragma.

db:exec("pragma table_info('Publication');") --check for table 'Publication'
Ignacio
I appreciate your help. I'm not able to get the solution working with your code as of yet though. print()'ing the statement outputs 0 whether the table name I've entered exists as a table or not.
Trae
Does `pragma table_info('tablename');` work from your Sqlite3 shell?
Ignacio