mirror of
https://github.com/kristoferssolo/SoloVim.git
synced 2026-02-04 06:42:05 +00:00
Update 24.01.2024
This commit is contained in:
30
bin/sql-format-via-python.py
Normal file
30
bin/sql-format-via-python.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import sys
|
||||
|
||||
import sqlparse
|
||||
|
||||
# TODO: Decide what to do about $/?
|
||||
# contents = contents.replace(f"${identifier}", f"__id_{identifier}")
|
||||
|
||||
contents = sys.stdin.read()
|
||||
for identifier in range(10):
|
||||
contents = contents.replace(f"?{identifier}", f"__id_{identifier}")
|
||||
|
||||
# for nightshadedude
|
||||
comma_first = False
|
||||
|
||||
result = sqlparse.format(
|
||||
contents,
|
||||
indent_columns=True,
|
||||
keyword_case="upper",
|
||||
identifier_case="lower",
|
||||
reindent=True,
|
||||
output_format="sql",
|
||||
indent_after_first=True,
|
||||
wrap_after=80,
|
||||
comma_first=comma_first,
|
||||
)
|
||||
|
||||
for identifier in range(10):
|
||||
result = result.replace(f"__id_{identifier}", f"?{identifier}")
|
||||
|
||||
print(result.strip())
|
||||
Reference in New Issue
Block a user