SQLAlchemy error MySQL server has gone away

前端 未结 6 2099
清酒与你
清酒与你 2021-02-05 07:58

Error OperationalError: (OperationalError) (2006, \'MySQL server has gone away\') i\'m already received this error when i coded project on Flask, but i cant underst

6条回答
  •  南方客
    南方客 (楼主)
    2021-02-05 08:35

    I just faced the same problem, which is solved with some effort. Wish my experience be helpful to others.

    Fallowing some suggestions, I used connection pool and set pool_recycle less than wait_timeout, but it still doesn't work.

    Then, I realized that global session maybe just use the same connection and connection pool didn't work. To avoid global session, for each request generate a new session which is removed by Session.remove() after processing.

    Finally, all is well.

提交回复
热议问题