def convertEkinprjs(local=None, server=None, project=None, username=None): """convert old ekin prjs in a db to new""" if local != None: DB = PDatabase(local=local) elif server != None: DB = PDatabase(server=server, username='******', port=8080, password='******', project=project) for f in DB['userfields']: if DB['userfields'][f]['field_type'] in ekintypes: print f for r in DB.getRecs(): rec = DB[r] if rec.has_key(f): E=rec[f] E.checkDatasets() for d in E.datasets: ek=E.getDataset(d) #ek.prettyPrint() rec[f] = E print DB.getChanged() DB.commit('converted ekin data') return
def convertEkinprjs(local=None, server=None, project=None, username=None): """convert old ekin prjs in a db to new""" if local != None: DB = PDatabase(local=local) elif server != None: DB = PDatabase(server=server, username='******', port=8080, password='******', project=project) for f in DB['userfields']: if DB['userfields'][f]['field_type'] in ekintypes: print f for r in DB.getRecs(): rec = DB[r] if rec.has_key(f): E = rec[f] E.checkDatasets() for d in E.datasets: ek = E.getDataset(d) #ek.prettyPrint() rec[f] = E print DB.getChanged() DB.commit('converted ekin data') return
def testLoading(): """Test loading times for large DB""" from PEATDB.PEATTables import PEATTableModel t1 = time() DB = PDatabase(local='large.fs') #DB = PDatabase(server='localhost', port=8080, username='******', # password='******', project='large') t2=time() print round(t2 - t1,2) print DB.getRecs() t3=time() print round(t3 - t2,2) print DB.meta t4=time() print t4 - t3 M = PEATTableModel(DB) print M t5=time() print t5 - t4 return
def testLoading(): """Test loading times for large DB""" from PEATDB.PEATTables import PEATTableModel t1 = time() DB = PDatabase(local='large.fs') #DB = PDatabase(server='localhost', port=8080, username='******', # password='******', project='large') t2 = time() print round(t2 - t1, 2) print DB.getRecs() t3 = time() print round(t3 - t2, 2) print DB.meta t4 = time() print t4 - t3 M = PEATTableModel(DB) print M t5 = time() print t5 - t4 return
def convertClass(): """Convert records to proper module name""" project='test' DB=PDatabase(server='localhost',port=8080, username='******',password='******', project=project) for k in DB.getRecs(): r=PEATRecord(k) rec = DB.data[k] print rec.__class__ for f in rec.getFields(): r[f] = rec[f] DB.data[k] = r print DB.data[k].__class__ DB.commit(note='convert') return
def testMemory(): """test memory behaviour of DB, how can cache be managed""" DB = PDatabase(server='localhost', username='******', password='******', project='novo') #DB = PDatabase(local='large.fs') print DB db = DB.db print db.cacheSize() for k in DB.getRecs()[:50]: #print k r=DB[k] r.name if db.cacheSize()>500: db.cacheMinimize() print db.cacheSize() return
def setDisplayFields(local=None, server=None, project=None, username=None): """Update display attributes for every cell""" if local != None: DB = PDatabase(local=local) elif server != None: DB = PDatabase(server=server, username=username, port=8080, password='******', project=project) for r in DB.getRecs(): rec = DB[r] for f in rec: x = rec.setDisplayAttribute(f, rec[f]) rec._display[f] = x print f, rec.getDisplayAttribute(f) #DB.commit('displ attrs') return
def convertClass(): """Convert records to proper module name""" project = 'test' DB = PDatabase(server='localhost', port=8080, username='******', password='******', project=project) for k in DB.getRecs(): r = PEATRecord(k) rec = DB.data[k] print rec.__class__ for f in rec.getFields(): r[f] = rec[f] DB.data[k] = r print DB.data[k].__class__ DB.commit(note='convert') return
def testMemory(): """test memory behaviour of DB, how can cache be managed""" DB = PDatabase(server='localhost', username='******', password='******', project='novo') #DB = PDatabase(local='large.fs') print DB db = DB.db print db.cacheSize() for k in DB.getRecs()[:50]: #print k r = DB[k] r.name if db.cacheSize() > 500: db.cacheMinimize() print db.cacheSize() return