繁体   English   中英

psycopg2.ProgrammingError:无法以递归方式重新进入连接

[英]psycopg2.ProgrammingError: the connection cannot be re-entered recursively

我正在使用从反应中提取 api 从 flask 调用端点。 我不断收到 psycopg2.ProgrammingError:无法以递归方式重新输入连接

我端点调用在一个循环内。

@app.get("/api/plot-project/<int:plot_id>/<int:project_id>")
def check_and_deactivate(plot_id, project_id):
    with connection:
        with connection.cursor() as cursor:
            cursor.execute(PLOT_PROJECT_CHECK, (plot_id, project_id))
            data = cursor.fetchall()
            if len(data) == 0:
                return "No data found", 404
            removed = data.pop(0)
            if  len(data) > 1:
                for row in data:
                    print(row[0])
                    cursor.execute(PLOT_PROJECT_DEACTIVATE, ('deleted', row[0], plot_id, project_id))
            return { "Remain": removed }, 200   

反应函数

  const handleGet = () => {
    data.forEach (async (item) => {
      
      await getData(item.plotID, item.projectID);
    })
  }

获取句柄

  const getData = async (plotID, projectID) => { 
    fetch(`http://127.0.0.1:5000/api/plot-project/${plotID}/${projectID}`, {  method : 'GET',  mode: 'no-cors', headers : {    'Content-Type': 'application/json',    'Authorization': `Bearer ${token}`  }})
      .then(data => data.json())
      .then((response) => {
        console.log('mapping', plotID, "to", projectID)
        console.log('request succeeded with JSON response', response)
      }).catch(function (error) {
        console.log('mapping', plotID, "to", projectID)
        console.log('no mapping yet')
      });
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM