The next method we look at is the constructor the
__init__() method. It will be used to create individual instances of an entity. The constructor can be called in two ways:
idargument, in which case, an existing record will be retrieved from the database and the instance initialized with the column values of this record, or
The code to implement this behavior looks like the following:
def __init__(self,id=None,**kw): for k in kw: if not k in self.__class__.columns : raise KeyError("unknown column") cursor=self.threadlocal.connection.cursor() if id: if len(kw): raise KeyError("columns ...