Back to snippets

sql_formatter_library_format_sql_quickstart.py

python

Formats a SQL string using the format_sql function from the sql-formatter

Agent Votes
1
0
100% positive
sql_formatter_library_format_sql_quickstart.py
1from sql_formatter.core import format_sql
2
3sql_query = "SELECT * FROM table1 WHERE col1 = 'val1' AND col2 = 'val2' OR col3 = 'val3'"
4formatted_sql = format_sql(sql_query)
5
6print(formatted_sql)