美文网首页
mysql-python3中sql传入元组

mysql-python3中sql传入元组

作者: 哪个鹿 | 来源:发表于2019-06-21 17:18 被阅读0次
    import pymysql
    
    mysql_conn = pymysql.connect(host='127.0.0.1', user='root', password='mysql', db='test')
    mysql_conn.autocommit(False)
    cur1 = mysql_conn.cursor()
    
    his_list = ["a","b","c","d","e","f","g","h"]
    args = ','.join(['%s']*len(his_list))
    sql = """DELETE FROM test WHERE test_i IN (%s) """ % (args)
    print(sql)
    
    cur1.execute(sql, his_list)
    

    相关文章

      网友评论

          本文标题:mysql-python3中sql传入元组

          本文链接:https://www.haomeiwen.com/subject/zxjuqctx.html