本文整理汇总了Python中sqlite3.html方法的典型用法代码示例。如果您正苦于以下问题:Python sqlite3.html方法的具体用法?Python sqlite3.html怎么用?Python sqlite3.html使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlite3
的用法示例。
在下文中一共展示了sqlite3.html方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _instrument
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import html [as 别名]
def _instrument(self, **kwargs):
"""Integrate with SQLite3 Python library.
https://docs.python.org/3/library/sqlite3.html
"""
tracer_provider = kwargs.get("tracer_provider")
tracer = get_tracer(__name__, __version__, tracer_provider)
dbapi.wrap_connect(
tracer,
sqlite3,
"connect",
self._DATABASE_COMPONENT,
self._DATABASE_TYPE,
self._CONNECTION_ATTRIBUTES,
)
示例2: adapt_datetime
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import html [as 别名]
def adapt_datetime(ts):
# http://docs.python.org/2/library/sqlite3.html#registering-an-adapter-callable
return time.mktime(ts.timetuple())
示例3: adapt_datetime
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import html [as 别名]
def adapt_datetime(ts):
# http://docs.python.org/2/library/sqlite3.html#registering-an-adapter-callable
return time.mktime(ts.timetuple())
示例4: get_url
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import html [as 别名]
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 ''
示例5: generate_insert_sqlstr_multivalue_tuple
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import html [as 别名]
def generate_insert_sqlstr_multivalue_tuple(table_name, column_name_list, column_value_lists):
# Formulate the sql string and value tuple for batch sql insert queries
# The key point is to use executemany function
# https://docs.python.org/2/library/sqlite3.html
sqlstr = 'INSERT INTO %s( %s ) VALUES ( %s )' % (table_name, ','.join(column_name_list),
','.join(['?'] * len(column_name_list)))
return (sqlstr, column_value_lists)
示例6: GetValues
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import html [as 别名]
def GetValues(self, table_names, column_names, condition):
"""Retrieves values from a table.
Args:
table_names (list[str]): table names.
column_names (list[str]): column names.
condition (str): query condition such as
"log_source == 'Application Error'".
Yields:
sqlite3.row: row.
Raises:
RuntimeError: if the database is not opened.
"""
if not self._connection:
raise RuntimeError('Cannot retrieve values database not opened.')
if condition:
condition = ' WHERE {0:s}'.format(condition)
sql_query = 'SELECT {1:s} FROM {0:s}{2:s}'.format(
', '.join(table_names), ', '.join(column_names), condition)
self._cursor.execute(sql_query)
# TODO: have a look at https://docs.python.org/2/library/
# sqlite3.html#sqlite3.Row.
for row in self._cursor:
yield {
column_name: row[column_index]
for column_index, column_name in enumerate(column_names)}
示例7: __init__
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import html [as 别名]
def __init__(self, *args, **kwargs):
# by default [py]sqlite3 checks that object methods are run in the same
# thread as the one that created the Connection or Cursor. If it finds
# they are not then an exception is raised.
# <https://docs.python.org/2/library/sqlite3.html#multithreading>
# Luckily for us we can switch this check off.
kwargs['check_same_thread'] = False
super(Connection, self).__init__(*args, **kwargs)
示例8: __init__
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import html [as 别名]
def __init__(self, databaseFilePath):
print("Intializing database at {}".format(databaseFilePath))
self.dbConnection = sqlite3.connect(databaseFilePath)
# This gives us the ability to access results by column name
# See https://docs.python.org/3/library/sqlite3.html#row-objects
self.dbConnection.row_factory = sqlite3.Row
self.initializeDatabaseTables()