You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from sql_metadata import Parser
def extract_columns_from_schema(schema_string):
# Initialize the parser with the schema string
parser = Parser(schema_string)
# Extract columns using sql_metadata
columns = parser.columns
return columns
# Example usage:
schema_string = """
CREATE TABLE accounts (
id INTEGER, /* comment */
username TEXT UNIQUE,
status TEXT,
online_at INTEGER,
hash TEXT UNIQUE,
uid TEXT UNIQUE,
test INTEGER,
usage INTEGER,
PRIMARY KEY (id)
)
"""
extracted_columns = extract_columns_from_schema(schema_string)
print(extracted_columns)
column username cant be detect because previous line has comment.
columns hashuidusage cant be detect because they are keyword, while SQLite create these column correctly.
It is stranger different response in ubuntu and Google Colab. In my ubuntu hashis detected .
In both, sql_metadata==2.12.0 is installed
I checked via parser.tokens:
ubuntu: value=hash,is_keyword=False
Google Colab= value=hash,is_keyword=True
The text was updated successfully, but these errors were encountered:
Bug that I see, it cant detect some columns:
column
username
cant be detect because previous line has comment.columns
hash
uid
usage
cant be detect because they are keyword, while SQLite create these column correctly.It is stranger different response in ubuntu and Google Colab. In my ubuntu
hash
is detected .In both, sql_metadata==2.12.0 is installed
I checked via parser.tokens:
ubuntu: value=hash,is_keyword=False
Google Colab= value=hash,is_keyword=True
The text was updated successfully, but these errors were encountered: