sql-metadata
sql-metadata copied to clipboard
extract columns from given schema same as PRAGMA table_info
Suppose we have a new schema as a text. How to extract columns from new schema same as PRAGMA table_info?
Actually I want to compare new schema (provided as a text string) with existing one in current database.
Sample:
new_schema='''
CREATE TABLE sqlite_schema(
type text,
name text,
tbl_name text,
rootpage integer,
sql text
)
'''
parser = sql_metadata.Parser(new_schema)
columns = parser.columns
parser.columns just returns columns name, but I need a format same as PRAGMA table_info:
(cid, name, type, notnull, dflt_value, pk)