728x90
반응형
CASE 1)
(24.02.10)
'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'You and what army?"\nI guess they\'re talking about you and me\nBaby, nobody will l\' at line 23'
python dedent에서 backspace 사용 남발로 제대로 된 query가 수행되지 않아 생기는 문제,,
Python 혹은 다른 언어들 대부분 들여 쓰기(indent)에 민감해 sqlparse 모듈로 query의 줄바꿈 upper case를 자동으로 전처리 해줄 수 있다.
import sqlparse
raw = 'select * from foo; select * from bar;'
print(sqlparse.format(raw, reindent=True, keyword_case='upper'))
SELECT *
FROM foo;
SELECT *
FROM bar;
https://github.com/andialbrecht/sqlparse
GitHub - andialbrecht/sqlparse: A non-validating SQL parser module for Python
A non-validating SQL parser module for Python. Contribute to andialbrecht/sqlparse development by creating an account on GitHub.
github.com
반응형
'Database' 카테고리의 다른 글
[UNION ALL] Colum Row 병합 (0) | 2024.02.16 |
---|---|
[Airflow] airflow-init alembic.script.revision.ResolutionError: No such revision or branch 오류 (0) | 2023.12.20 |
[Airflow] airflow db 초기화 오류 (0) | 2023.12.20 |
[airflow] airflow root 권한 docker 접속 (0) | 2023.11.26 |
[airflow] airflow-init-1 exited (0) | 2023.11.26 |