本文整理汇总了Python中database.DatabaseManager.retrieve_from_fts方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseManager.retrieve_from_fts方法的具体用法?Python DatabaseManager.retrieve_from_fts怎么用?Python DatabaseManager.retrieve_from_fts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database.DatabaseManager
的用法示例。
在下文中一共展示了DatabaseManager.retrieve_from_fts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search_locally_with_partial
# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import retrieve_from_fts [as 别名]
def search_locally_with_partial(partial, exclude_ref_types=None):
start_index = int(partial['start_index'])
limit = int(partial['limit']) if 'limit' in partial else None
# Apparently Python DB API and Sqlite and commas (,), parans ((,)), and colons (:) do not play nice with FTS?
search_strings = u" ".join([unicode(v) for k, v in partial['description'].items()])
for ref_type in exclude_ref_types:
search_strings += u" AND NOT (tags:{})".format(ref_type)
uuids = dbm.retrieve_from_fts(search_strings, start_index=start_index, limit=limit)
def get_cite_for_uuid(result):
ref_type = result['tags']
uuid = result['uuid']
if ref_type == GAME_CITE_REF:
table = dbm.GAME_CITATION_TABLE
if ref_type == PERF_CITE_REF:
table = dbm.PERFORMANCE_CITATION_TABLE
if ref_type == STATE_CITE_REF:
table = dbm.GAME_SAVE_TABLE
if ref_type in (GAME_CITE_REF, PERF_CITE_REF):
db_values = dbm.retrieve_attr_from_db('uuid', uuid, table, limit=1)[0]
citation = dbm.create_cite_ref_from_db(ref_type, db_values)
else:
citation = dbm.retrieve_save_state(uuid=uuid)[0]
citation['ref_type'] = STATE_CITE_REF
return citation
# Results should already be sorted by rank
citations = map(get_cite_for_uuid, uuids)
return citations