For some reason I can't find a way to get the equivalents of sqlite's interactive shell commands:
.tables
.dump
using the Python sqlite3 API.
Is there anything like that?
For some reason I can't find a way to get the equivalents of sqlite's interactive shell commands:
.tables
.dump
using the Python sqlite3 API.
Is there anything like that?
You can fetch the list of tables and schemata by querying the SQLITE_MASTER table:
I'm not familiar with the Python API but you can always use
After a lot of fiddling I found a better answer at sqlite docs for listing the metadata for the table, even attached databases.
The key information is to prefix table_info, not my_table with the attachment handle name.
In Python:
Watch out for my other answer. There is a much faster way using pandas.
Here's a short and simple python program to print out the table names and the column names for those tables.
I've implemented a sqlite table schema parser in PHP, you may check here: https://github.com/c9s/LazyRecord/blob/master/src/LazyRecord/TableParser/SqliteTableDefinitionParser.php
You can use this definition parser to parse the definitions like the code below: