Project

General

Profile

« Previous | Next » 

Revision 2339

sql.py: Added table_cols() and use it in pkey()

View differences:

lib/sql.py
599 599

  
600 600
##### Database structure queries
601 601

  
602
def table_cols(db, table, recover=None):
603
    return list(col_names(select(db, table, limit=0, order_by=None,
604
        recover=recover)))
605

  
602 606
def pkey(db, table, recover=None):
603 607
    '''Assumed to be first column in table'''
604
    return col_names(select(db, table, limit=0, order_by=None,
605
        recover=recover)).next()
608
    return table_cols(db, table, recover)[0]
606 609

  
607 610
def index_cols(db, table, index):
608 611
    '''Can also use this for UNIQUE constraints, because a UNIQUE index is

Also available in: Unified diff