MCPcopy Index your code
hub / github.com/clips/pattern / update

Method update

pattern/db/__init__.py:963–978  ·  view source on GitHub ↗

Updates the row with the given id.

(self, id, *args, **kwargs)

Source from the content-addressed store, hash-verified

961 return self._insert_id()
962
963 def update(self, id, *args, **kwargs):
964 """ Updates the row with the given id.
965 """
966 # Table.update(1, age=3)
967 # Table.update(1, {"age":3})
968 # Table.update(all(filter(field="name", value="Taxi")), age=3)
969 commit = kwargs.pop("commit", True) # As fieldname, use abs(Table.name, "commit").
970 if len(args) == 0 and len(kwargs) == 1 and isinstance(kwargs.get("values"), dict):
971 kwargs = kwargs["values"]
972 if len(args) == 1 and isinstance(args[0], dict):
973 a=args[0]; a.update(kwargs); kwargs=a
974 kv = ", ".join("`%s`=%s" % (k, self.db.escape(v)) for k, v in kwargs.items())
975 q = "update `%s` set %s where %s;" % (self.name, kv,
976 not isinstance(id, Group) and cmp(self.primary_key, id, "=", self.db.escape) \
977 or id.SQL(escape=self.db.escape))
978 self.db.execute(q, commit)
979
980 def delete(self, id, commit=True):
981 """ Removes the row which primary key equals the given id.

Callers 1

insertMethod · 0.45

Calls 8

lenFunction · 0.85
cmpFunction · 0.85
popMethod · 0.45
getMethod · 0.45
escapeMethod · 0.45
itemsMethod · 0.45
SQLMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected