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

generated SQL should be validated before execution #494

Open
wgong opened this issue Jun 14, 2024 · 1 comment
Open

generated SQL should be validated before execution #494

wgong opened this issue Jun 14, 2024 · 1 comment

Comments

@wgong
Copy link

wgong commented Jun 14, 2024

Is your feature request related to a problem? Please describe.
I asked the following question on SQLite chinook db:

vn.ask(question="which table stores customer's orders")

The answer is correct, yet Vanna tried to execute an invalid SQL

The "invoices" table stores customers' orders. It contains information about each invoice made by a customer, including the customer ID, invoice date, billing address, total amount, and foreign key references to the customer and invoice items

Here is the error log

Couldn't run sql:  Execution failed on sql 'The "invoices" table stores customers' orders. It contains information about each invoice made by a customer, including the customer ID, invoice date, billing address, total amount, and foreign key references to the customer and invoice items.': near "The": syntax error

Describe the solution you'd like
use sqlparse.parse(sql)

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
not sure

Additional context
Add any other context or screenshots about the feature request here.
N/A

@zainhoda
Copy link
Contributor

Yeah, we already use an is_sql_valid in the web app between vn.generate_sql and vn.run_sql, which we should bring over to vn.ask

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