本文整理汇总了Python中horizons.util.dbreader.DbReader.execute_many方法的典型用法代码示例。如果您正苦于以下问题:Python DbReader.execute_many方法的具体用法?Python DbReader.execute_many怎么用?Python DbReader.execute_many使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.util.dbreader.DbReader
的用法示例。
在下文中一共展示了DbReader.execute_many方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_map
# 需要导入模块: from horizons.util.dbreader import DbReader [as 别名]
# 或者: from horizons.util.dbreader.DbReader import execute_many [as 别名]
def create_map():
"""
Create a map with a square island (20x20) at position (20, 20) and return the path
to the database file.
"""
# Create island.
fd, islandfile = tempfile.mkstemp()
os.close(fd)
db = DbReader(islandfile)
db("CREATE TABLE ground(x INTEGER NOT NULL, y INTEGER NOT NULL, ground_id INTEGER NOT NULL, action_id TEXT NOT NULL, rotation INTEGER NOT NULL)")
db("CREATE TABLE island_properties(name TEXT PRIMARY KEY NOT NULL, value TEXT NOT NULL)")
db("BEGIN TRANSACTION")
tiles = []
for x, y in Rect.init_from_topleft_and_size(0, 0, 20, 20).tuple_iter():
if (0 < x < 20) and (0 < y < 20):
ground = GROUND.DEFAULT_LAND
else:
# Add coastline at the borders.
ground = GROUND.SHALLOW_WATER
tiles.append([x, y] + list(ground))
db.execute_many("INSERT INTO ground VALUES(?, ?, ?, ?, ?)", tiles)
db("COMMIT")
# Create savegame with the island above.
fd, savegame = tempfile.mkstemp()
os.close(fd)
db = DbReader(savegame)
read_savegame_template(db)
db("BEGIN TRANSACTION")
db("INSERT INTO island (x, y, file) VALUES(?, ?, ?)", 20, 20, islandfile)
db("COMMIT")
return savegame