本文整理匯總了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()
))