Search code examples
pythonpymysqldatabase-cursor

python : pymysql error cursor closed when using two databses or multiple databases with cursor


I'm using two databases now, one is for reading and the other one is for writing. when I connected just one db it worked fine but when I made two connection it started to give me an error.

Traceback (most recent call last):

 File "/home/user/PycharmProjects/a/pymysql/cursors.py", line 71, in _get_db
raise err.ProgrammingError("Cursor closed")

pymysql.err.ProgrammingError: Cursor closed

what can I do to fix this error?


Solution

  • I solved this problem by myself by finding out that I was using two cursor which exactly has same name. So either one closed before query executed.