所以我尝试使用cdecimal在我的数据库中存储货币值。SQLAlchemy Doc
import sys
import cdecimal
sys.modules["decimal"] = cdecimal
我将PostgreSQL数据库连接成这样:
^{pr2}$我已经建立了这样的模型:
class Exchange(Base):
amount = Column(Numeric)
...
def __init__(self, amount):
self.amount = cdecimal.Decimal(amount)
但是,每次执行此操作时,都会出现以下错误:
ProgrammingError: (ProgrammingError) can't adapt type 'cdecimal.Decimal' 'INSERT INTO...
我做错什么了?在
这个对我有用请试试这个
注意:我的电脑中没有pgsql,所以我尝试了mysql。在
相关问题 更多 >
编程相关推荐