def main(cur, url=config.FTP_URI): """ Check users data and save stats and logs""" rows = get_data(url) logs = {} for row in rows: set_stat(cur, row[0], row[1]) if not check_passwd(row[2]): logs[row[1]] = row[0] save_log(logs)
def test_write_db(self): init_stat(self.cur) date = datetime.now() name = u'test' r = set_stat(self.cur, date, name) self.assertTrue(r) self.con.commit() r = self.cur.execute('select date,name,cnt from visits where name=:name', {'date': date.strftime('%Y-%m-%d'), 'name': name}).fetchone() self.assertEqual(r, (date.strftime('%Y-%m-%d'), name, 1))