def write_analyses_to_csv(p, ms): man = IsotopeDatabaseManager(bind=False, connect=False) man.db.trait_set( name="pychrondata", kind="mysql", host=os.environ.get("HOST"), username="******", password=os.environ.get("DB_PWD"), ) man.connect() db = man.db with db.session_ctx(): h = datetime.now() l = h - timedelta(days=60) ans = db.get_analyses_date_range(l, h, mass_spectrometers=ms) with open(p, "w") as wfile: writer = csv.writer(wfile) n = len(ans) for i, ai in enumerate(ans): # if not (i + 1) % 10: # print '{}/{}'.format(i + 1, n) try: t = ai.timestamp # print ai.id pc = ai.peak_center.center print ai.analysis_timestamp, ai.record_id, t, pc writer.writerow([t, pc]) except AttributeError, e: print e
def write_analyses_to_csv(p, ms): man = IsotopeDatabaseManager(bind=False, connect=False) man.db.trait_set(name='pychrondata', kind='mysql', host='129.138.12.160', username='******', password='******') man.connect() db = man.db with db.session_ctx(): h = datetime.now() l = h - timedelta(days=60) ans = db.get_analyses_date_range(l, h, mass_spectrometers=ms) with open(p, 'w') as wfile: writer = csv.writer(wfile) n = len(ans) for i, ai in enumerate(ans): if not (i + 1) % 10: print '{}/{}'.format(i + 1, n) try: t = ai.timestamp pc = ai.peak_center.center # print ai.analysis_timestamp, t, pc writer.writerow([t, pc]) except AttributeError: pass
def isotope_manager_factory(name='pychrondata_dev'): man = IsotopeDatabaseManager(connect=False, bind=False) man.db.kind = 'mysql' man.db.name = name man.db.password = '******' man.db.username = '******' man.db.host = 'localhost' man.connect() return man