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

Version 6 (modified by italomaia, 13 years ago) (diff)

timetime doesn't exist . datetime is the right lib

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(
    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:

To give it some parameters, it goes like this:

The WHERE if not used, is assumed, so, this would work as well: 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.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.q.members==10, orderBy= -A.q.created ))

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

temp = 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