So, I'm trying to use cdecimal to store monetary values ββin my database. SQLAlchemy Doc
import sys import cdecimal sys.modules["decimal"] = cdecimal
I linked my PostgreSQL database like this:
sqlalchemy.url = postgresql+psycopg2://user: password@host :port/dbname
I installed the model something like this:
class Exchange(Base): amount = Column(Numeric) ... def __init__(self, amount): self.amount = cdecimal.Decimal(amount)
However, when I do this, I get the following error:
ProgrammingError: (ProgrammingError) can't adapt type 'cdecimal.Decimal' 'INSERT INTO...
What am I doing wrong?
source share