You can change decimal to cdecimal more reliable way, forcing it to happen before any other code runs. When launched, the Python interpreter will read any .pth files and execute any import statements it contains, which allows us to run code before executing any program. I documented the cdecimal swap cdecimal more detail on my blog - essentially you need to create two files:
First site-packages/my_patches.pth , which contains:
import my_patches
Secondly, site-packages/my_patches.py , which contains the swap code:
import sys import cdecimal
Then you should not have problems with SQLAlchemy, since it will not be able to run a preliminary replacement.
source share