Project

General

Profile

« Previous | Next » 

Revision 2443

sql.py: Specify log_levels for minor queries so they can be excluded from the debug output

View differences:

sql.py
307 307
    
308 308
    def with_savepoint(self, func):
309 309
        savepoint = 'level_'+str(self._savepoint)
310
        self.run_query('SAVEPOINT '+savepoint)
310
        self.run_query('SAVEPOINT '+savepoint, log_level=4)
311 311
        self._savepoint += 1
312 312
        try: 
313 313
            try: return_val = func()
......
315 315
                self._savepoint -= 1
316 316
                assert self._savepoint >= 0
317 317
        except:
318
            self.run_query('ROLLBACK TO SAVEPOINT '+savepoint)
318
            self.run_query('ROLLBACK TO SAVEPOINT '+savepoint, log_level=4)
319 319
            raise
320 320
        else:
321
            self.run_query('RELEASE SAVEPOINT '+savepoint)
321
            self.run_query('RELEASE SAVEPOINT '+savepoint, log_level=4)
322 322
            self.do_autocommit()
323 323
            return return_val
324 324
    
......
685 685

  
686 686
def table_row_count(db, table, recover=None):
687 687
    return value(run_query(db, *mk_select(db, table, [sql_gen.row_count],
688
        order_by=None, start=0), recover=recover))
688
        order_by=None, start=0), recover=recover, log_level=3))
689 689

  
690 690
def table_cols(db, table, recover=None):
691 691
    return list(col_names(select(db, table, limit=0, order_by=None,
692
        recover=recover)))
692
        recover=recover, log_level=4)))
693 693

  
694 694
def pkey(db, table, recover=None):
695 695
    '''Assumed to be first column in table'''
......
739 739
) s
740 740
ORDER BY attnum
741 741
''',
742
            {'table': table, 'index': index}, cacheable=True)))
742
            {'table': table, 'index': index}, cacheable=True, log_level=4)))
743 743
    else: raise NotImplementedError("Can't list index columns for "+module+
744 744
        ' database')
745 745

  
......
770 770
    index = sql_gen.as_Table(clean_name(str(col)))
771 771
    col = sql_gen.to_name_only_col(col)
772 772
    try: run_query(db, 'CREATE INDEX '+index.to_str(db)+' ON '+table.to_str(db)
773
        +' ('+col.to_str(db)+')', recover=True, cacheable=True)
773
        +' ('+col.to_str(db)+')', recover=True, cacheable=True, log_level=3)
774 774
    except DuplicateTableException: pass # index already existed
775 775

  
776 776
def index_pkey(db, table, recover=None):
......
782 782
    index = sql_gen.as_Table(table.name+'_pkey')
783 783
    col = sql_gen.to_name_only_col(pkey(db, table, recover))
784 784
    run_query(db, 'ALTER TABLE '+table.to_str(db)+' ADD CONSTRAINT '
785
        +index.to_str(db)+' PRIMARY KEY('+col.to_str(db)+')', recover=recover)
785
        +index.to_str(db)+' PRIMARY KEY('+col.to_str(db)+')', recover=recover,
786
        log_level=3)
786 787

  
787 788
def add_row_num(db, table):
788 789
    '''Adds a row number column to a table. Its name is in row_num_col. It will
789 790
    be the primary key.'''
790 791
    table = sql_gen.as_Table(table).to_str(db)
791 792
    run_query(db, 'ALTER TABLE '+table+' ADD COLUMN '+row_num_col
792
        +' serial NOT NULL PRIMARY KEY')
793
        +' serial NOT NULL PRIMARY KEY', log_level=3)
793 794

  
794 795
def tables(db, schema='public', table_like='%'):
795 796
    module = util.root_module(db.db)

Also available in: Unified diff