How do I list a DB's tables with Python's DB API?
Failing that, is there another way to do it?
Thanks
All Database Tables If you want to list all tables in the Oracle database, you can query the dba_tables view. SELECT table_name FROM dba_tables ORDER BY table_name ASC; This view (and all others starting with dba_) are meant for database administrators.
If you are running the sqlite3 command-line access program you can type ". tables" to get a list of all tables. Or you can type ". schema" to see the complete database schema including all tables and indices.
The DBAPI does not have a function for this so unfortunately you need to use SQL that is specific to the database engine (there is no standardized way to list tables).
SHOW TABLES
SELECT tablename FROM pg_tables WHERE schemaname = 'public'
SELECT name FROM sqlite_master WHERE type = 'table'
SELECT Distinct TABLE_NAME FROM information_schema.TABLES
SELECT table_name FROM all_tables
SELECT table_name FROM tables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With