我正在構建一個在MySQL上使用SQLAlchemy的django應用程序。我使用cdecimal而不是內置的Decimal。 在我的一個表中,我有一個數值列(value = Column(Numeric(10, 5)
)。 當我創造我的Django應用程序此表的新條目,用下面的SQL回聲:Python cdecimal.Decimal和SQLAlchemy _mysql_exceptions.Warning
INSERT INTO my_table (date, value) VALUES (2012-03-11, 875334.670)
這將導致以下異常時拋出承諾:
_mysql_exceptions.Warning: Out of range value for column 'value' at row 1
當我運行同樣的查詢在MySQL客戶端中,根本沒有問題。 我甚至嘗試包裹,增加了與入門代碼:
import warnings
from sqlalchemy import exc as sa_exc
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=sa_exc.SAWarning)
這是怎麼回事?
謝謝!
請你給建立在我們的系統中的問題的例子嗎? – Nilesh 2012-03-12 06:29:28