本文整理汇总了Python中model.Session.add_all方法的典型用法代码示例。如果您正苦于以下问题:Python Session.add_all方法的具体用法?Python Session.add_all怎么用?Python Session.add_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Session
的用法示例。
在下文中一共展示了Session.add_all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initialize_device
# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import add_all [as 别名]
def initialize_device():
"""
Set up the Device info into the database.
By this time, the HardwareDefinition and SoftwareDefinition
entries must be entered.
"""
session = Session()
hd = session.query(HardwareDefinition).one()
sd = session.query(SoftwareDefinition).one()
device = Device(id=hd.serial_number,
interior_sensor=hd.interior_sensor,
exterior_sensor=hd.exterior_sensor)
device.hardware_version = hd.hardware_version
device.software_version = sd.software_version
device.database_service = True # database always set to True
device.device_service = sd.device_service
device.grainbin_service = sd.grainbin_service
session.add(device)
# set grainbin info
if sd.grainbin_service:
grainbins = initialize_grainbin(device.id, hd.grainbin_reader_count)
device.grainbin_count = len(grainbins)
session.add_all(grainbins)
session.commit()
session.close()
return
示例2: popula
# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import add_all [as 别名]
def popula():
session = Session()
session.add_all( # TODO: fazer construtores
FornecedorPJ(cpf="00000000000134", nome="Banco do Brasil S/A"),
FornecedorPF(cpf="00000000000", nome="Fulano de tal"),
)