0

Here is my code snippet:-

import sqlite3
database = "sample.db"
def dbConnection(database):
    try:
        connection = sqlite3.connect(database)
        db_cursor = connection.cursor()
        db_cursor.execute("show tables;")
        rows = db_cursor.fetchall()
        for row in rows:
            print row
        connection.close()
    except sqlite3.Error, e:
        print "Error in connection",e
dbConnection("enb.db")

It is raising this exception:-

Error in connection near "show": syntax error

I can't see anything wrong with the syntax as I just want to view the tables in the database. What could be the problem here?Thanks

2 Answers 2

1

"SHOW TABLES" is not supported by SQLite. It is valid for other databases such as MySQL.

SQLite sql reference

How to 'show tables' in SQLite

Sign up to request clarification or add additional context in comments.

Comments

0

SQLite doesn't support "show" functions. You can use SELECT name FROM sqlite_master where type='table'. I found it from this thread, Android sqlite show tables

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.