I have been trying to dump data into a mysql database using sqlalchemy. While I try do so its gives the error sqlalchemy.exc.ArgumentError: List argument must consist only of tuples or dictionaries
. The following code is being used for insertion.
def insert_data(db, table, rows):
db.execute(f"INSERT INTO {table} VALUES (%s)", rows)
db.commit()
The content in rows
is as follows.
[(1, 'asdsewadada', 'lajsdljasld', 'lol@gmail.com', 51)]
So, what I am inserting is list of tuples and I am still getting the same error.
1条答案
按热度按时间fcipmucu1#
Can you format your row data like below and give it a try try :