Replies: 2 comments 6 replies
-
pymsql is used only for creation of db and migrations. Normally ormar uses aiomysql cause it uses databases to run queries. That means that you probably call create database multiple times (can be run in multiple threads or processes depending on workers config). In production you should be using alembic to run migrations, and those should be run before the app even starts, in a separate step in deployment. |
Beta Was this translation helpful? Give feedback.
-
It seems it's coming from aiomysql and would happen regardless if you use ormar or not aio-libs/aiomysql#614 But at the same time I'm using mysql in production for a long time already and it works fine. How do you deploy to production? Can you downgrade the system version and/or change system and/or downgrade python version? Since aiomysql is not really longer supported there are some new drivers appearing. One of them is asyncmy. There is a PR for databases but it was not merged yet. Can you try to install databases from this branch and change your url to use this driver? encode/databases#382 |
Beta Was this translation helpful? Give feedback.
-
So, i've got ormar running on prod(mysql) with uvicorn workers(15) and everything works fine, but sometime i'm getting
pymysql.err.InternalError: Packet sequence number wrong - got 35 expected 1
when i query database, after a few seconds in google i found out that it's because pymysql works fine only in singlethread and if you want to create a multithread app you need to create a multiple amount of instances. Well i'm creating database & other stuff in my app.state so it shouldn't be an issue.Is there maybe any examples of this because i'm stuck for along time?
refs:
PyMySQL/PyMySQL#422
https://www.uvicorn.org/settings/#production
Beta Was this translation helpful? Give feedback.
All reactions