2012-05-09 1 views
0

私はこのクラスを定義していますSqlalchemy:IDENTITY主キー列を持つSybaseデータベーステーブルに新しい行を挿入するにはどうすればよいですか?

class Trade(Base): 
    __tablename__ = 'TRADE' 
    __table_args__ = {'quote':False} 

    id = Column(Integer, name='id_trade', primary_key=True) 
    idImnt = Column(Integer, ForeignKey('INSTRUMENT.id_imnt'), name='id_imnt') 
... 

私は戻ってデータベースに新しい貿易インスタンスをコミットしようとしたとき、私はこのエラーを得た:

Instance <Trade at 0x954fd90> has a NULL identity key. If this is 
an auto-generated value, check that the database table allows generation of 
new primary key values, and that the mapped Column object is configured to 
expect these generated values. Ensure also that this flush() is not 
occurring at an inappropriate time, such as within a load() event. 

私はid列の定義で何かを逃したと思います。解決策は何ですか?

編集:

デスクトップPC:WinXPの

のSybaseサーバ:15.5

答えて

0

それはドライバの問題であることが判明。

Sybase ODBCドライバ12.5は簡単な選択と更新で問題なく動作しますが、ID列を持つテーブルにデータを挿入すると失敗します。

15.5ドライバに切り替えると問題が解決しました。

関連する問題