Project

General

Profile

« Previous | Next » 

Revision 1915

sql.py: pkey(): Changed to use the connection-wide caching mechanism rather than its own custom cache. DbConn.__getstate__(): Don't pickle the debug callback.

View differences:

lib/sql.py
86 86
        self.log_debug = log_debug
87 87
        
88 88
        self.__db = None
89
        self.pkeys = {}
90 89
        self.query_results = {}
91 90
    
92 91
    def __getattr__(self, name):
......
96 95
    
97 96
    def __getstate__(self):
98 97
        state = copy.copy(self.__dict__) # shallow copy
98
        state['log_debug'] = None # don't pickle the debug callback
99 99
        state['_DbConn__db'] = None # don't pickle the connection
100 100
        return state
101 101
    
......
321 321
def pkey(db, table, recover=None):
322 322
    '''Assumed to be first column in table'''
323 323
    check_name(table)
324
    if table not in db.pkeys:
325
        db.pkeys[table] = col_names(run_query(db,
326
            'SELECT * FROM '+table+' LIMIT 0', recover=recover)).next()
327
    return db.pkeys[table]
324
    return col_names(run_query(db,
325
        'SELECT * FROM '+table+' LIMIT 0', recover=recover)).next()
328 326

  
329 327
def index_cols(db, table, index):
330 328
    '''Can also use this for UNIQUE constraints, because a UNIQUE index is

Also available in: Unified diff