raiseException("You either forgot to save the id at insert for "
"class '{0}' or id this object doesn't know its id "
"yet because it has never been inserted into the"
"data base".format(self.__class__.__name__))
returnself._id
@id.setter
defid(self,value):
self._id=value
def__conform__(self,foo):
iffooisISQLQuote:
returnself
@classmethod
deffrom_select(cls,fetched_row):
raiseException("Your forgot to implement the select method for class "
"'{0}'!".format(self.__class__.__name__))
def_sql_members(self):
raiseException("Till, you forgot to implement the property "
"__sql_members for the class '{0}'".format(
self.__class__.__name__))
definsert(self,schema):
params=list()
# print (self.types)
forkey,valueinself.entries.items():
# print (key)
# print (self.types[key])
# print (value)
params.append(self.types[key](value))
request="INSERT INTO {0}.{1} ({2}) VALUES ({3}) RETURNING id".format(schema,self.table_name,','.join(self.entries.keys()),','.join(["%s"foriteminparams])),params
returnrequest
defupdate(self,schema):
params=list()
forkey,valueinself.entries.items():
# print (key)
# print (self.types[key])
# print (value)
params.append(self.types[key](value))
request="UPDATE {0}.{1} SET ({2}) = ({3}) WHERE id = {4}".format(schema,self.table_name,','.join(self.entries.keys()),','.join(["%s"foriteminparams]),self.id),params