From: Oleg B. <ph...@ph...> - 2011-08-21 09:16:41
|
On Sat, Aug 20, 2011 at 11:15:20PM +0000, Mark wrote: > How would I do this in SQLObject? > > UPDATE > Table > SET > some_text = CONCAT(some_text, 'text') > WHERE > id = 57 > > Is it just > > table = Table.get(57) > table.some_text = table.some_text + "text" It depends on what you really want. Functionally, your SQL and python code do the same thing but in different ways. SQL code works on the server side and doesn't update the client side; python code performs concatenation on the client side and sends an UPDATE like that: UPDATE table SET some_text = new_text WHERE id = 57 If you really want to call CONCAT or any other function do it in SQLObject like this: from sqlobject.sqlbuilder import Update, func connection.query( Update(Table.sqlmeta.table, {'some_text': func.CONCAT(Table.q.some_text, 'text')}, Test.q.id==57)) You have to ask SQLObject to update the client side because you updated the server side and you don't want python and SQL sides to by desynchronized: table.sync() Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |