本文整理汇总了Python中db.Db.get_total_count方法的典型用法代码示例。如果您正苦于以下问题:Python Db.get_total_count方法的具体用法?Python Db.get_total_count怎么用?Python Db.get_total_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Db
的用法示例。
在下文中一共展示了Db.get_total_count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: single_whorl_uniqueness
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import get_total_count [as 别名]
def single_whorl_uniqueness(whorl_name, whorl_value):
print "here"
db = Db()
db.connect()
md5_whorl_value = FingerprintHelper.value_or_md5({whorl_name: whorl_value})[whorl_name]
try:
count = db.get_whorl_value_count(whorl_name, md5_whorl_value, config.epoched)
except TypeError:
return {"status": "Error: that value has not yet been recorded for '" + whorl_name + "'"}
total = db.get_total_count(config.epoched)
uniqueness = {"bits": round(-log(count / float(total), 2), 2), "one_in_x": round(float(total) / count, 2)}
return uniqueness
示例2: _fetch_counts
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import get_total_count [as 别名]
def _fetch_counts(whorls):
db = Db()
db.connect()
# result dict. 'total' is the total number of entries, 'sig_matches' is
# the number matching signature in whorls, other keys are variables in
# signature.
counts = {}
# query an incrementally updated totals table which has an index on
# unique (variable, value)
md5_whorls = FingerprintHelper.value_or_md5(whorls)
for i in FingerprintHelper.whorl_names:
counts[i] = db.get_whorl_value_count(i, md5_whorls[i], config.epoched)
total = db.get_total_count(config.epoched)
matching = db.get_signature_matches_count(whorls["signature"], config.epoched)
return counts, total, matching