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

sam
  • 127
  • 3
  • 13

2 Answers2

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

Community
  • 1
  • 1
Jeremy Allen
  • 6,434
  • 2
  • 26
  • 31
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

Community
  • 1
  • 1
Shang
  • 85
  • 7