本文整理汇总了Python中box.Box.get_blob_string方法的典型用法代码示例。如果您正苦于以下问题:Python Box.get_blob_string方法的具体用法?Python Box.get_blob_string怎么用?Python Box.get_blob_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类box.Box
的用法示例。
在下文中一共展示了Box.get_blob_string方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_stop_list_table
# 需要导入模块: from box import Box [as 别名]
# 或者: from box.Box import get_blob_string [as 别名]
def write_stop_list_table(out_file, stop_list_map):
out_file.write("CREATE TABLE IF NOT EXISTS trip_stops (id INTEGER PRIMARY KEY, blob STRING);\n")
for stop_list_id, lst in stop_list_map.items():
box = Box()
box.add_short(len(lst))
for stop_id, sequence in lst:
try:
box.add_string(stop_id)
box.add_short(sequence)
except:
print((stop_id, sequence))
raise
out_file.write("INSERT INTO trip_stops VALUES (%d, %s);\n" % (
stop_list_id, box.get_blob_string()
))
示例2: write_arrivals_table
# 需要导入模块: from box import Box [as 别名]
# 或者: from box.Box import get_blob_string [as 别名]
def write_arrivals_table(out_file, arrivals_map):
out_file.write("CREATE TABLE IF NOT EXISTS arrivals (id INTEGER PRIMARY KEY, blob STRING);\n")
for arrival_id, lst in arrivals_map.items():
box = Box()
box.add_short(len(lst))
for arrival_seconds, departure_seconds in lst:
if arrival_seconds % 60 != 0:
raise Exception("arrival_seconds % 60 != 0")
if (arrival_seconds / 60) > 0xffff or arrival_seconds < 0:
raise Exception("arrival_seconds out of range")
box.add_short(arrival_seconds/60)
#box.add_int(departure_seconds)
out_file.write("INSERT INTO arrivals VALUES (%d, %s);\n" % (
arrival_id, box.get_blob_string()
))