Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate sql error #800

Open
yqz945 opened this issue Apr 17, 2024 · 1 comment
Open

Generate sql error #800

yqz945 opened this issue Apr 17, 2024 · 1 comment

Comments

@yqz945
Copy link

yqz945 commented Apr 17, 2024

from pypika import Query, Table

customers = Table('batch')
q_str =str(Query.from_(customers).select(customers.id))
print(q_str)

SELECT "id" FROM "batch"

Because the Double quotation marks " exists,

ProgrammingError: (pymysql.err.ProgrammingError) (1064, '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 '"batch"' at line 1')
[SQL: SELECT "id" FROM "batch"]

How does is works?

@JasonDeRice
Copy link

you can try q_str.get_sql(quote_char=None), that will remove the quotation around fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants