I have problem with cleaning comments and empty lines from already existing sql file. The file has over 10k lines so cleaning it manually is not an option.
I have a litt
Adding an updated answer :)
import sqlparse
sql_example = """--comment
SELECT * from test;
INSERT INTO test VALUES ('
-- test
a
');
"""
print sqlparse.format(sql_example, strip_comments=True).strip()
Output:
SELECT * from test; INSERT INTO test VALUES (' -- test a ');
It achieves the same result but also covers all other corner cases and more concise