MCPcopy Index your code
hub / github.com/webpy/webpy / delete

Method delete

web/db.py:1130–1158  ·  view source on GitHub ↗

Deletes from `table` with clauses `where` and `using`. >>> db = DB(None, {}) >>> name = 'Joe' >>> db.delete('foo', where='name = $name', vars=locals(), _test=True)

(self, table, where, using=None, vars=None, _test=False)

Source from the content-addressed store, hash-verified

1128 return db_cursor.rowcount
1129
1130 def delete(self, table, where, using=None, vars=None, _test=False):
1131 """
1132 Deletes from `table` with clauses `where` and `using`.
1133
1134 >>> db = DB(None, {})
1135 >>> name = 'Joe'
1136 >>> db.delete('foo', where='name = $name', vars=locals(), _test=True)
1137 <sql: "DELETE FROM foo WHERE name = 'Joe'">
1138 """
1139 if vars is None:
1140 vars = {}
1141
1142 where = self._where(where, vars)
1143
1144 q = "DELETE FROM " + table
1145 if using:
1146 q += " USING " + sqllist(using)
1147
1148 if where:
1149 q += " WHERE " + where
1150
1151 if _test:
1152 return q
1153
1154 db_cursor = self._db_cursor()
1155 self._db_execute(db_cursor, q)
1156 if not self.ctx.transactions:
1157 self.ctx.commit()
1158 return db_cursor.rowcount
1159
1160 def _process_insert_query(self, query, tablename, seqname):
1161 return query

Callers 3

deleteMethod · 0.45
__delitem__Method · 0.45
cleanupMethod · 0.45

Calls 5

_whereMethod · 0.95
_db_cursorMethod · 0.95
_db_executeMethod · 0.95
sqllistFunction · 0.85
commitMethod · 0.45

Tested by

no test coverage detected