我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用sqlite3.html()。
def adapt_datetime(ts): # http://docs.python.org/2/library/sqlite3.html#registering-an-adapter-callable return time.mktime(ts.timetuple())
def get_url(self,url): #headers = {'user-agent': 'Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.0.9.2372 Mobile Safari/537.10+'} headers = {'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1'} try: r = requests.get(url,headers=headers) html = HTMLParser.HTMLParser().unescape(r.content.decode('utf-8')) return html except: return ''
def close(self): self.conn.commit() # Change connection's row_factory to a log entry so we can # plug the fetch results directly into a JSONResponse # https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.row_factory
def update_uuid(self): self.mutex.lock() # https://docs.python.org/2/library/sqlite3.html try: cur = MainCon.cur cur.execute(''' SELECT uuid FROM `UUID` ; ''') uuid_in_db = cur.fetchall() self.mutex.unlock() uuids = [x[0] for x in uuid_in_db] logger.debug('SystemDevices.refresh_state') SystemDevices.refresh_state() logger.debug('SystemDevices.refresh_state END') deviceDict = SystemDevices.deviceDict uuid_list = [] for dev_id, dev in deviceDict.items(): uuid = dev['uuid'] fstype = dev['fstype'] label = dev['label'] major_dnum, minor_dnum = dev_id uuid_list.append(uuid) if not uuid in uuids: cur.execute('''INSERT INTO UUID (included, uuid, alias, fstype,name,label,major_dnum,minor_dnum, path) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)''', (False, dev['uuid'], dev['mountpoint'], dev['fstype'], dev['name'], dev['label'], major_dnum, minor_dnum, dev['mountpoint'])) else: cur.execute('''UPDATE UUID SET fstype=?,name=?,label=?,major_dnum=?,minor_dnum=?,path=? WHERE uuid=?''', (dev['fstype'], dev['name'], dev['label'], major_dnum, minor_dnum, dev['mountpoint'], dev['uuid']) ) MainCon.con.commit() except Exception as e: self.show_statusbar_warning_msg_SIGNAL.emit(str(e)) logger.error(str(e)) self.mutex.unlock() logger.debug('init_table') for uuid in uuid_list: self.init_table(uuid, clear_table=False) logger.debug('init_table END') try: MainCon.con.commit() except Exception as e: logger.error(str(e)) # self.con.commit() # commit