如何在Flask上使用mysqldb执行多个查询

问题描述

我一直在尝试使我的代码正常工作,但是找不到为什么它不执行它的工作。 我正在尝试将数据放入数据库中,因为它似乎只执行一个.... 代码是:

def setCubesValues(value):
    MysqL.connection.autocommit(on=True)
    tabVal = value.split(';;')
    del tabVal[0]
    for i in range(0,len(tabVal)):
        tabi = tabVal[i]
        cur = MysqL.connection.cursor()
        responseCur = cur.execute('SELECT * FROM idcudetoaction where id_cube = "' + tabi +'"')
        if responseCur == 1:
            curResultInsert = cur.execute('update idcudetoaction set action = "' + tabi +'" where id_cube = ' + str(i))
        else:
            curResultInsert = cur.execute('insert into idcudetoaction (id_cube,action) values (' + str(i)+',"' + tabi +'")')
    return jsonify(curResultInsert);

问题是我有7个值,但是只有将它放在数据库中...

有什么帮助吗? :) 谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)