MySQLConverter' object has no attribute '_tuple_to_mysql' exception with mysql-connector

后端 未结 3 611
孤独总比滥情好
孤独总比滥情好 2021-01-23 03:56

I have 8 kinds of data that I would like to insert into a mysql table through mysql-connector using python. I have looked at some documents saying that it is better to use

3条回答
  •  独厮守ぢ
    2021-01-23 04:42

    Antti Haapala has a great answer but you could also tidy it up by using zip to build the row to insert for you

    for row in zip(URL, Title, Content, Month, Date, Year, Time1, TimeZone):
        dbcur.execute(
            """INSERT INTO scripting (URL, Title, Content, Month, Date, Year, Time, TimeZone)
               VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")""",
               row)
        dbcon.commit()
    

提交回复
热议问题