Update database with multiple SQL Statments

后端 未结 4 1335
终归单人心
终归单人心 2021-02-06 06:48

I am using mysql connector.Python 1.0.9 downloaded from MySQL site.

I have a sample table here

DROP TABLE IF EXISTS my_table; 
CREATE TABLE my_table
(id          


        
4条回答
  •  无人及你
    2021-02-06 07:28

    Another option is to use executemany, as follows:

    sql=('insert into articulos (descripcion, precio) values(%s,%s)')  
    data=[('naranjas',22), ("pomelos", 29), ("frutillas", 130)]
    
    cursor.executemany(sql,data) 
    

提交回复
热议问题