abel deuring schrieb:
> I'm trying to declare an SQLObject derived class, where a column
> contains a computed value; the SQL query should look like:
>
> SELECT x, my_function(x) FROM mytable
Is 'my_function' an SQL function?
Remember, with SQLObject you don't select rows, you retrieve objects.
Easiest thing would be to add a getter to your SQLObject class:
class MyClass(SQLObject):
col = StringCol()
def _get_computed_value(self):
return my_function(self.col)
where 'my_funtion' is a *Python* function, defined somewhere else, and then do:
for obj in MyClass.select():
print obj.col, obj.computed_value
> SELECT x, y, y != my_function(x) FROM mytable
>
> Reading the docs, I could not figure out, how a colunm definition
> should look for the last column.
Use 'func' from the sqlbuilder module:
from sqlobject.sqlbuilder import *
MyClass.select(MyClass.q.y != func.my_function(MyClass.q.y))
Chris
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss