Failure to obtain data often occurs during sqlalchemy operation, but there is data in mysql.

recently, it often appears when using sqlalchemy+python+gunicorn to develop a small project. Sqlalchemy reads the data and returns None, but it is possible to view the data in the database. As a novice, I suspect that there is something wrong with my writing with sqlalchemy code. I hope you can take a look at it for me.
is my code for inserting data:

clipboard.png
clipboard.png

:
clipboard.png

with chance, sometimes the user has just registered successfully, and I see that there is data in the table, but the next second when I query the user table (through the custom search method), what is returned is None,. Is there a problem with what I wrote? no one around me contacted python, so I came here to consult you!


take a look at it in debugger? See here that you don't create a session in your create_consumer_user , but add it directly. Once the session is close, you need to recreate it

.
Menu