-
Notifications
You must be signed in to change notification settings - Fork 76
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
fixing problems with comments that have %
and fixing incompatibility with MySQL
#362
Conversation
997e8e0
to
357cded
Compare
a847958
to
2a399ab
Compare
%
and fixing incompatibility with MySQL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
Tested locally these code cells and it works:
%%sql --save many_passengers --no-execute
SELECT *
FROM taxi
WHERE passenger_count > 3
-- remove top 1% outliers for better visualization
AND trip_distance < 18.93
Returns a table
%sql --with many_passengers select * from many_passengers limit 2
Returns a plot
%sqlplot histogram --table many_passengers --column trip_distance --with many_passengers
) | ||
|
||
if use_backticks: | ||
template_ = template_.replace('"', "`") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in the future we can make it dynamic because there might be exceptional DBs, and we don't want to have to pass use_backticks
and check it every time we run a query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm passing it depending on the dialect type, but yes, we need to come up with a more reliable way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lg, added small comment
@@ -482,9 +486,13 @@ def _histogram(table, column, bins, with_=None, conn=None, facet=None): | |||
"""Compute bins and heights""" | |||
if not conn: | |||
conn = sql.connection.Connection.current.session | |||
use_backticks = sql.connection.Connection.is_use_backtick_template() | |||
else: | |||
# TODO: fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to open an issue on this.
I think I have a lot similar fix in https://github.com/ploomber/jupysql/pull/339/files But LGTM |
Describe your changes
This PR fixes several problems:
"
and backticks depending on the dialecttext
objects to theexecute
method to prevent SQLAlchemy from interpreting stuff like%name
as query parameterIssue number
Closes #X
Checklist before requesting a review
pkgmt format
📚 Documentation preview 📚: https://jupysql--362.org.readthedocs.build/en/362/