Table List
To show (display) the list of tables created in
a database the following program can be used.
import sqlite3
con =
sqlite3.connect('Academy.db')
cursor = con.cursor()
cursor.execute("SELECT name
FROM sqlite_master WHERE type='table';")
print(cursor.fetchall())
[('Student',), ('Appointment',),
('Person',)]
The above program (Example 15.3-1) display the
names of all tables created in ‘Academy. db’ database. The master table holds the key information about your database tables
and it is called sqlite_master
So far, you have been using the Structured
Query Language in Python scripts. This chapter has covered many of the basic
SQL commands. Almost all sql commands can be executed by Python SQLite module.
You can even try the other commands discussed in the SQL chapter.
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.