def get_table_columns ( dbconn , tablename ) : cur = dbconn . cursor ( ) cur . execute ( "PRAGMA table_info('%s');" % tablename ) info = cur . fetchall ( ) cols = [ ( i [ 1 ] , i [ 2 ] ) for i in info ] return cols
get the columns of database table python
Return a list of tuples specifying the column name and type
def get_table_columns(dbconn, tablename):
    """
    Return a list of tuples specifying the column name and type
    """
    cur = dbconn.cursor()
    cur.execute("PRAGMA table_info('%s');" % tablename)
    info = cur.fetchall()
    cols = [(i[1], i[2]) for i in info]
    return cols