wiki:SQLObjectQuickRef
Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Here you can find quick references to SQLObject, like consult examples and etc

example class:

from datetime import datetime
class A(SQLObject):
    members = IntCol()
    name = StringCol(default="Annonimous",alternateID=True)
    created = DateTimeCol(default=datetime.now)
    friends = MultipleJoin("B")
    owner = ForeignKey("C")

class B(SQLObject):
    name = StringCol()

class C(SQLObject):
    name = StringCol()

Getting tuples from database The simplest way of retrieve data from the db is as follows:

mySQLObjectClass.select()

To give it some parameters, it goes like this:

A.select(WHERE(A.q.members==10))

The WHERE if not used, is assumed, so, this would work as well:

A.select( A.q.members==10 )

It returns a group of results that fit the consult. If you want to order it by creation, do like this:

A.select( A.q.members==10, orderBy=A.q.created )

Note that the result will come sorted from older to newer. If you want it sorted from newer to older, do this:

temp = A.select( A.q.members==10, orderBy= -A.q.created ))

And for a limited result, the recommended is as follows:

temp = A.select( A.q.members==10, orderBy= -A.q.created )[:10]

If you pay attention, you'll see that the slice is done to the consult result. It happens because the slicing operator is overwritten and, will work just like a limit statement in your query.

If you want to retrieve your tuple through the id, just do this:

A.get( myClassId )

To retrieve the tuple by it's primary key, just do this:

A.byName( primaryKey ) ##it may throw a SQLObjectNotFound exception