You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have noticed that when using the aurora_data_api, when using the cursor.executemany method for a MySQL DB, I cannot use a list of Tuples, only a list of dicts is processed correctly, while the "official" MySQL Python docs give an example of using a Tuple and not a dict.
When I try to use a list of Tuples with cursor.excecutemany, like seen below, I get an error message regarding Tuples:
INSERT INTO aurora_data_api_test
(name, doc, num, ts)
VALUES (%s, %s, %s, %s)
""" data = [(f"name-{i}", f"doc-{i}", "5.0", "2020-09-1713:49:32.780180") for i in range(2048)] response = cursor.executemany(sql, data)
[ERROR] AttributeError: 'tuple' object has no attribute 'items'
I believe that it is related to this part in your init.py file, which expects to get a dict:
def _format_parameter_set(self, parameters):
return [self.prepare_param(k, v) for k, v in parameters.items()]
Can you please help me with understanding this gap? The only way that it seems to work with auroro_data_api, is if I do this instead:
sql = """
INSERT INTO aurora_data_api_test
(name, doc, num, ts)
VALUES (:name, :doc, :num, :ts)
"""
response = cursor.executemany(sql, [
{
"name": f"name-{i}",
"doc": f"doc-{i}",
"num": "5.0",
"ts": "2020-09-17 13:49:32.780180"
} for i in range(2048)]
)
If I run the code above and use my local docker image with the latest MySQL image, I get this error:
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 ':name, :doc, :num, :ts)' at line 3")
The text was updated successfully, but these errors were encountered:
yuvaljacob
changed the title
Using Tuples in cursor.excecutemany does not work with the aurora_data_api.connect()
Using Tuples in cursor.excecutemany does not work with aurora_data_api.connect()
Feb 10, 2022
Thanks for reporting - this is just to acknowledge that this seems like an issue in the mysql implementation. I'll take a look when I get a chance to spin up a test RDS instance again.
I have noticed that when using the aurora_data_api, when using the cursor.executemany method for a MySQL DB, I cannot use a list of Tuples, only a list of dicts is processed correctly, while the "official" MySQL Python docs give an example of using a Tuple and not a dict.
When I try to use a list of Tuples with cursor.excecutemany, like seen below, I get an error message regarding Tuples:
[ERROR] AttributeError: 'tuple' object has no attribute 'items'
I believe that it is related to this part in your init.py file, which expects to get a dict:
Can you please help me with understanding this gap? The only way that it seems to work with auroro_data_api, is if I do this instead:
If I run the code above and use my local docker image with the latest MySQL image, I get this error:
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 ':name, :doc, :num, :ts)' at line 3")
The text was updated successfully, but these errors were encountered: