How can I get the list of all the available tables in sqlite programmatically?
Asked
Active
Viewed 2.9k times
20
-
@MaheshBabu: Jhaliya's answer is correct according to me. So please try that out. – Parth Bhatt Mar 17 '11 at 05:25
-
Possible duplicate of [How to list the tables in an SQLite database file that was opened with ATTACH?](http://stackoverflow.com/questions/82875/how-to-list-the-tables-in-an-sqlite-database-file-that-was-opened-with-attach) – KeksArmee Jan 02 '17 at 04:14
4 Answers
41
try this :
SELECT * FROM sqlite_master where type='table';

rofrol
- 14,438
- 7
- 79
- 77

Mitesh Khatri
- 3,935
- 4
- 44
- 67
11
Use the below sql statement to get list of all table in sqllite data base
SELECT * FROM dbname.sqlite_master WHERE type='table';
The same question asked before on StackOverFlow.
How to list the tables in an SQLite database file that was opened with ATTACH?

Community
- 1
- 1

Jhaliya - Praveen Sharma
- 31,697
- 9
- 72
- 76
-
1+1 for your answer because you have even provided the link in case it is not clear. :-) – Parth Bhatt Mar 17 '11 at 05:26
0
con = sqlite3.connect('db.sqlite')
cur = con.cursor()
cur.execute('''
SELECT tbl_name
FROM sqlite_master
WHERE type = 'table';
''')
print(cur.fetchall())

Raccoon_Alert
- 1
- 1
-
Remember that Stack Overflow isn't just intended to solve the immediate problem, but also to help future readers find solutions to similar problems, which requires understanding the underlying code. This is especially important for members of our community who are beginners, and not familiar with the syntax. Given that, **can you [edit] your answer to include an explanation of what you're doing** and why you believe it is the best approach? – Jeremy Caney Jan 11 '23 at 00:54