Re: [SQLObject] cannot insert with Sybase
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Oleg B. <ph...@ph...> - 2009-03-04 10:56:01
|
On Wed, Mar 04, 2009 at 10:31:31AM +0000, wzi...@co... wrote: > from sqlobject import * > > class titles( SQLObject ): > > title_id = IntCol() > title = StringCol() > > class sqlmeta: > print 'class sqlmeta' > idName = 'title_id' [skip] > newKey = 1234 > newTitle = "Mystery Book" > book_b = titles.titles(title_id=newKey, title=newTitle) Throughout entire SQLObject the 'id' column is called 'id'. After you named your column 'title_id' in sqlmeta you have to use 'id' name for the column: book_b = titles.titles(id=newKey, title=newTitle) Without that SQLObject thinks id is None and creates a new id by asking the backend - see sqlobject/sybase/sybaseconnection.py, methods _queryInsertId() and insert_id(). insert_id() creates a new id (0) and then SQLObject tries to SELECT the row back by that id. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |