-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Support writes in mysql #1935
Support writes in mysql #1935
Conversation
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.
Thanks! Please see comments.
redash/query_runner/mysql.py
Outdated
columns = self.fetch_columns([(i[0], types_map.get(i[1], None)) for i in cursor.description]) | ||
rows = [dict(zip((c['name'] for c in columns), row)) for row in data] | ||
|
||
queries = query.rstrip(';').split(';') |
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.
That's not such a good idea, think of the following (contrived) example:
>>> "SELECT ';'".split(';')
["SELECT '", "'"]
But see the fix here: e02fdb3 for supporting multiple queries.
Once you rebase with latest, you can simplify the logic you implemented here.
redash/query_runner/mysql.py
Outdated
error = None | ||
|
||
if transaction: | ||
connection.commit() |
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.
Why not commit above?
redash/query_runner/mysql.py
Outdated
else: | ||
transaction = True | ||
columns = [{'name': 'Row(s) Affected', | ||
'type': types_map.get(str(type(rows_count)).upper(), None)}] |
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.
Wouldn't it be always an integer? In which case you can use TYPE_INTEGER
constant.
Do we need more changes for this? |
Is this still needed following the changes in #3003? |
I'm not sure how much need there is for writes from redash - with the #3003 changes you can now achieve the same thing; eg with a redash query like:-
|
Following #3003, closing this. @mfouilleul, if you still think this is needed (and willing to put in the work to update it to the changes in Thanks. |
Avoid trigging errors during insert, update, deletes.