Revision 3286
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
916 | 916 |
autoanalyze(db, table) |
917 | 917 |
return cur |
918 | 918 |
|
919 |
def mk_delete(db, table, cond=None): |
|
920 |
''' |
|
921 |
@param cond sql_gen.Code WHERE condition. e.g. use sql_gen.*Cond objects. |
|
922 |
@return str query |
|
923 |
''' |
|
924 |
query = 'DELETE FROM '+table.to_str(db) |
|
925 |
if cond != None: query += '\nWHERE '+cond.to_str(db) |
|
926 |
|
|
927 |
query = with_explain_comment(db, query) |
|
928 |
|
|
929 |
return query |
|
930 |
|
|
931 |
def delete(db, table, *args, **kw_args): |
|
932 |
'''For params, see mk_delete() and run_query()''' |
|
933 |
recover = kw_args.pop('recover', None) |
|
934 |
cacheable = kw_args.pop('cacheable', False) |
|
935 |
log_level = kw_args.pop('log_level', 2) |
|
936 |
|
|
937 |
cur = run_query(db, mk_delete(db, table, *args, **kw_args), recover, |
|
938 |
cacheable, log_level=log_level) |
|
939 |
autoanalyze(db, table) |
|
940 |
return cur |
|
941 |
|
|
919 | 942 |
def last_insert_id(db): |
920 | 943 |
module = util.root_module(db.db) |
921 | 944 |
if module == 'psycopg2': return value(run_query(db, 'SELECT lastval()')) |
Also available in: Unified diff
sql.py: Added mk_delete() and delete()