执行单条:
P_list=[2,'name']
MySQL:cursor.execute('select * from user where id = ? and name = ? ', (P_list))
Oracle:cursor.execute('select * from user where id = :id and name = :name ', (P_list))
执行多条:
sql= 'insert into user (id,name) values(?,?)'
content_list=[(1,'a'),(2,'b'),(3,'c')]
MySQL:cursor.executemany(sql,content_list)#执行多条SQL
网友评论