-
Notifications
You must be signed in to change notification settings - Fork 290
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
Convert SQL string to pypika.Query #325
Comments
Hi @ranamihir, |
For another project that uses pypika, I've written a grammar using sly that parses SQL into PyPika objects. It's not exhaustive and only handles expressions, not the entire query string, however it might serve as a good example for anyone who is interested in extending it. I've shard it as a gist: https://gist.github.com/twheys/5635a932ca6cfce0d114a86fb55f6c80 |
Here's the code that runs the eval
|
@twheys I am trying to use your code, but int your
but that didn't work. I get the following error:
and the beginning of the sql file looks something like:
|
Spent some time searching for something like this but couldn't find anything. The gist was very helpful. First time with Sly so took some time to get familiar with it.. in doing so I ended up getting 99% of the way to a package so I ended up publishing it here: https://github.com/pahwaranger/sql_to_pypika |
Hi,
I'm wondering if there's any function for converting a given SQL string to a
pypika.Query
object? If not, I think it'd be a very helpful feature. People who are more comfortable (or prefer) writing SQL, but also need programmatic flexibility in certain cases would really benefit a lot.E.g. something like:
returns:
The text was updated successfully, but these errors were encountered: