Created
April 28, 2022 04:52
-
-
Save xnuinside/fa8e5cbf08b5547f11cc3807d9368ca4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlparse | |
# put here in raw_sql your query | |
raw_sql = 'select column1, column2 from schema.table_name;' | |
# parse query | |
statements = sqlparse.parse(raw_sql) | |
# columns | |
print("Columns: ", statements[0].tokens[2]) | |
# table name | |
print("Table name with schema: ", statements[0].tokens[6]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment