def insertdb(ID, Password, a_type): with sqlite3.connect(db_file) as db: cursor = db.cursor() access_key = myapi.get_access_key(ID, Password) cookies = myapi.get_cookies(access_key) if access_key == '-1': logging.info('密码错误') return if a_type != 4: sql = """INSERT INTO Account VALUES ("%s", "%s","%s","%s",0,"3770834",%d,0,0,0,0,0,0,0,0,0,0)""" % ( ID, Password, access_key, cookies, a_type) else: sql = """INSERT INTO Account VALUES ("%s", "%s","%s","%s",0,"3770834",%d,0,0,0,0,1,1,1,0,0,0)""" % ( ID, Password, access_key, cookies, a_type) try: cursor.execute(sql) logging.info("%s 插入成功" % ID) db.commit() except: logging.info('插入数据失败!') logging.info(sql) db.rollback()
def flushdb(db,bilibili_temp): key_temp = myapi.get_access_key(bilibili_temp.ID,bilibili_temp.Password) cookies_temp = str(myapi.get_cookies(key_temp)) cursor = db.cursor() sql = "UPDATE Account SET access_key = '%s' , cookies = \"%s\" WHERE ID = '%s'" % (key_temp,cookies_temp,bilibili_temp.ID) try: cursor.execute(sql) db.commit() except: print '更新数据失败!' db.rollback() return (key_temp,json.loads(cookies_temp.replace("'", '"')))
def flush_db(bilibili_temp): with sqlite3.connect(db_file) as db: key_temp = myapi.get_access_key(bilibili_temp.ID, bilibili_temp.Password) cookies_temp = str(myapi.get_cookies(key_temp)) cursor = db.cursor() sql = "UPDATE Account SET access_key = '%s' , cookies = \"%s\" WHERE ID = '%s'" % ( key_temp, cookies_temp, bilibili_temp.ID) try: cursor.execute(sql) db.commit() except: logging.info('更新数据失败!') db.rollback() return key_temp, json.loads(cookies_temp.replace("'", '"'))
def insertdb(db,ID,Password,a_type): cursor = db.cursor() access_key=myapi.get_access_key(ID,Password) cookies=myapi.get_cookies(access_key) if(access_key == '-1'): print '密码错误' return if a_type != 4: sql = """INSERT INTO Account VALUES ("%s", "%s","%s","%s",0,"3770834",%d,False,False,False,False,False,False,False,False,0,0)""" %(ID,Password,access_key,cookies,a_type) else: sql = """INSERT INTO Account VALUES ("%s", "%s","%s","%s",0,"3770834",%d,False,False,False,False,True,True,True,False,0,0)""" %(ID,Password,access_key,cookies,a_type) try: cursor.execute(sql) print "%s 插入成功" %ID db.commit() except: print '插入数据失败!' print sql db.rollback()