Beispiel #1
0
 def glue(self):
     update_columns, update_params = lists_from_dict(self.updates)
     where_str, where_params = Where(self.cond).glue()
     sql = 'UPDATE %(table)s SET %(updates)s %(where)s' % {
         'table': quote(self.table),
         'updates': ','.join('%s = %%s' % glue_col(c)[0] for c in update_columns),
         'where': where_str,
     }
     return sql.strip(), update_params + where_params
Beispiel #2
0
 def glue(self):
     raw_columns, insert_params = lists_from_dict(self.inserts)
     columns = []
     for o in raw_columns:
         columns.append(glue_col(o)[0])
     sql = 'INSERT INTO %(table)s (%(columns)s) VALUES (%(values)s) RETURNING id' % {
         'table': quote(self.table),
         'columns': ','.join(columns),
         'values': ','.join('%s' for _ in columns),
     }
     return sql.strip(), insert_params