sql-metadata icon indicating copy to clipboard operation
sql-metadata copied to clipboard

extract columns from given schema same as PRAGMA table_info

Open AliM1988 opened this issue 1 year ago • 0 comments

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)

AliM1988 avatar Jul 05 '24 05:07 AliM1988