Project

General

Profile

« Previous | Next » 

Revision 2086

sql.py: Added add_row_num(). put_table(): Add row_num to pkeys_table, so it can be joined with in_table's pkeys.

View differences:

lib/sql.py
516 516
    else: raise NotImplementedError("Can't list constraint columns for "+module+
517 517
        ' database')
518 518

  
519
def add_row_num(db, table):
520
    '''Adds a row number column named `row_num` to a table'''
521
    check_name(table)
522
    run_query(db, 'ALTER TABLE '+table+' ADD COLUMN row_num serial NOT NULL')
523

  
519 524
def tables(db, schema='public', table_like='%'):
520 525
    module = util.root_module(db.db)
521 526
    params = {'schema': schema, 'table_like': table_like}
......
601 606
        cur = with_parsed_errors(db, insert_)
602 607
        if row_ct_ref != None and cur.rowcount >= 0:
603 608
            row_ct_ref[0] += cur.rowcount
609
        
610
        # Add row_num to pkeys_table, so it can be joined with in_table's pkeys
611
        add_row_num(db, pkeys_table)
612
        
604 613
        return pkeys_table
605 614
    except DuplicateKeyException, e: raise

Also available in: Unified diff