Issues with pyodbc cursor with multiple users

I am not sure if this is an important issue, but I wanted to bring it to the attention of the admins. I have a multipage application that runs behind a reverse proxy using nginx. Within the application I have a connection to the database to pull some data for building a predictive model.

The application works great, and I have been able to bring in multiple users to use it. However, if 2 users click on the same page that has the pyodbc connection, at about the same time, one of them gets a Function sequence error. The thing is, the connection is only used to read data from a view and nothing is being inserted. The user who got the error can navigate to a different page and come back to the required page and this time there is no error.

I made sure that the odbc connection is not persisting across sessions and that each one is unique, but the error persists. My nginx config also persists the websocket connection, so I know that there is no cross talk between sessions. If the issue was only with stored procs, I would have understood, but even when reading views, this issue persists.

I have worked around this to use json files to store the data locally (I have a fairly big machine) and serving up app using those files. This has fixed my issue. I wanted to find out if anybody else has had this issue. I can not paste the necessary code right now, but I will try it with a simpler example to see if the error comes back.

Hi @Kasi -

In the pyodbc documentation, it mentions that it is not thread-safe. I wonder if there’s unintentional sharing somewhere that you aren’t expecting. In any case, thanks for letting us know, and if you figure out what is going on please do let us know.

Best,
Randy