Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python flask sqlite无法从数据库中删除行_Python_Sqlite_Flask - Fatal编程技术网

Python flask sqlite无法从数据库中删除行

Python flask sqlite无法从数据库中删除行,python,sqlite,flask,Python,Sqlite,Flask,使用flask时,我似乎无法从sqlite数据库中删除行 @app.route('/deletePath',methods=['POST']) def deletePath(): if 'toDelPathIndex' in request.form: pathIndex = request.form['toDelPathIndex'] if not isInt(pathIndex):

使用flask时,我似乎无法从sqlite数据库中删除行

@app.route('/deletePath',methods=['POST'])
    def deletePath():
        if 'toDelPathIndex' in request.form:
            pathIndex = request.form['toDelPathIndex']
            if not isInt(pathIndex):
                    errorMessage="Given Path Index "+pathIndex+" is not valid"
                    return render_template('addPath.html',error=errorMessage)

            cur = g.db.cursor()
            cur.execute('select id,ParentDir from Path')
            rows=cur.fetchall()
            found=0
            for row in rows:
                    if int(pathIndex) == row[0]:
                            Dir=row[1]
                            found = 1
            if found == 0:
                    errorMessage="Given Path Index "+pathIndex+" is not present in database"
                    return render_template('addPath.html',error=errorMessage)
            g.db.execute('delete from Path where id=' + pathIndex)
            g.db.commit()
            g.db.execute('delete from SnippetDirs where ParentDir=?',(Dir,))
            g.db.commit()
            return redirect(url_for('addPath_GET'))
    else:
                    errorMessage="Please give me a path index to try and delete"
                    return render_template('addPath.html',error=errorMessage)
更具体地说,这条线

g.db.execute('delete from SnippetDirs where ParentDir=?',(Dir,))
g.db.execute('delete from Path where id=' + pathIndex)
未按预期工作,因为数据库的大小未减小 而这条线

g.db.execute('delete from SnippetDirs where ParentDir=?',(Dir,))
g.db.execute('delete from Path where id=' + pathIndex)
正在正确执行并从其中一个表中删除所需的行


我不知道我做错了什么

提示:如果int(pathIndex)==行[0]:为false,当int(pathIndex)==行[0]:为false时,
Dir的值是多少?
控件不会进入该行,它只打印一条错误消息。