Revision 1905
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
273 | 273 |
if missing: warnings.warn(DbWarning( |
274 | 274 |
'SELECT statement missing a WHERE, LIMIT, or OFFSET clause: '+query)) |
275 | 275 |
|
276 |
return run_query(db, query, conds.values(), cacheable, recover)
|
|
276 |
return run_query(db, query, conds.values(), recover, cacheable)
|
|
277 | 277 |
|
278 |
def insert(db, table, row, returning=None, recover=None): |
|
278 |
def insert(db, table, row, returning=None, recover=None, cacheable=True):
|
|
279 | 279 |
'''@param returning str|None An inserted column (such as pkey) to return''' |
280 | 280 |
check_name(table) |
281 | 281 |
cols = row.keys() |
... | ... | |
290 | 290 |
check_name(returning) |
291 | 291 |
query += ' RETURNING '+returning |
292 | 292 |
|
293 |
return run_query(db, query, row.values(), recover) |
|
293 |
return run_query(db, query, row.values(), recover, cacheable)
|
|
294 | 294 |
|
295 | 295 |
def last_insert_id(db): |
296 | 296 |
module = util.root_module(db.db) |
Also available in: Unified diff
sql.py: insert(): Cache insert queries by default. This works because any DuplicateKeyException, etc. would be cached as well. This saves many inserts for rows that we already know are in the database.