Monday, February 12, 2007

SQLObject

SQLObject is a really neat Object Relational Manager for Python. But imho not very well documented.

I have been developing a class which can handle the usual Create, Read, Update and Delete (CRUD) pattern. I'm using Kid for templates.

Here are some bites of the code:

# getting a tables columns
for col in table.sqlmeta.columnList:
print col.name
columnType=table.sqlmeta.columnDefinitions[col.name]
if col.foreignKey==None:
# normal column
else:
# relationship column

# getting remove and add method in join
rm=getattr(obj,'remove' + join.addRemoveName)
rm(record) # remove a record from relation

No comments: