当前位置: 首页>>代码示例>>Python>>正文


Python DBSession.add_all方法代码示例

本文整理汇总了Python中sngconnect.database.DBSession.add_all方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.add_all方法的具体用法?Python DBSession.add_all怎么用?Python DBSession.add_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sngconnect.database.DBSession的用法示例。


在下文中一共展示了DBSession.add_all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from sngconnect.database import DBSession [as 别名]
# 或者: from sngconnect.database.DBSession import add_all [as 别名]
 def setUp(self):
     super(TestActivate, self).setUp()
     feed_template = FeedTemplate(
         id=1,
         name='Feed template 1',
         modbus_bandwidth=9600,
         modbus_port='/dev/ttyS0',
         modbus_parity='EVEN',
         modbus_data_bits=8,
         modbus_stop_bits=1,
         modbus_timeout=5,
         modbus_endianness='BIG',
         modbus_polling_interval=120,
         dashboard_layout='IMAGE',
     )
     feed = Feed(
         id=1,
         template=feed_template,
         name=u"Feed 1",
         description=u"Description",
         latitude=20.5,
         longitude=15.3,
         created=pytz.utc.localize(datetime.datetime.utcnow()),
         api_key='some-api-key',
         activation_code='some-activation-code',
         activation_code_regenerated=pytz.utc.localize(
             datetime.datetime.utcnow()
         ),
     )
     self.activation_code = feed.activation_code
     DBSession.add_all([
         feed_template,
         feed,
     ])
开发者ID:fikander,项目名称:sngtec-sngconnect,代码行数:36,代码来源:views.py

示例2: generate_data

# 需要导入模块: from sngconnect.database import DBSession [as 别名]
# 或者: from sngconnect.database.DBSession import add_all [as 别名]
def generate_data():
    user = User(
        name='User',
        email='[email protected]',
        phone='+48123456789',
        activated=pytz.utc.localize(datetime.datetime.utcnow()),
        role_user=True,
        timezone_tzname='Europe/Warsaw'
    )
    user.set_password('user')
    kid = User(
        name='Kid',
        email='[email protected]',
        phone='+48123456789',
        activated=pytz.utc.localize(datetime.datetime.utcnow()),
        role_user=True,
        timezone_tzname='Europe/Warsaw'
    )
    kid.set_password('kid')
    maintainer = User(
        name='Maintainer',
        email='[email protected]',
        phone='+48123456789',
        activated=pytz.utc.localize(datetime.datetime.utcnow()),
        role_maintainer=True,
        timezone_tzname='Europe/Warsaw'
    )
    maintainer.set_password('maintainer')
    supplier = User(
        name='Supplier',
        email='[email protected]',
        phone='+48123456789',
        activated=pytz.utc.localize(datetime.datetime.utcnow()),
        role_supplier=True,
        timezone_tzname='Europe/Warsaw'
    )
    supplier.set_password('supplier')
    admin = User(
        name='Admin',
        email='[email protected]',
        phone='+48123456789',
        activated=pytz.utc.localize(datetime.datetime.utcnow()),
        role_administrator=True,
        timezone_tzname='Europe/Warsaw'
    )
    admin.set_password('admin')
    DBSession.add_all([user, kid, maintainer, supplier, admin])
    transaction.commit()
开发者ID:fikander,项目名称:sngtec-sngconnect,代码行数:50,代码来源:create_test_users.py

示例3: create_test_data2

# 需要导入模块: from sngconnect.database import DBSession [as 别名]
# 或者: from sngconnect.database.DBSession import add_all [as 别名]
def create_test_data2():
    starting_id = 200000
    feed_template = FeedTemplate(
        id=starting_id,
        name=u"NIBE Modbus 40",
        dashboard_layout="GAUGES",
        modbus_bandwidth=9600,
        modbus_port='/dev/ttyS0',
        modbus_parity='EVEN',
        modbus_data_bits=8,
        modbus_stop_bits=1,
        modbus_timeout=5,
        modbus_endianness='BIG',
        modbus_polling_interval=120
    )
    feed = Feed(
        id=starting_id,
        template=feed_template,
        name=u"Instalacja pompy NIBE",
        description=u"Instalacja pompy NIBE",
        address=u"ul. Bysławska 82 lok. 312\n04-993 Warszawa",
        latitude=52.158427,
        longitude=21.198292,
        api_key='aaaa1tgDLBbzoghjCBDrpcD2NXUCP1WGFUDwm7baQTgmgueS5eU5c4W9EpLrnorJKC4DMfKe255YbwPvAJ7ppbD21NAs8XLk4XQb',
        created=pytz.utc.localize(datetime.datetime.utcnow())
    )
    feed.regenerate_activation_code()
    user = DBSession.query(User).filter(User.email == '[email protected]').one()
    feed_user = FeedUser(
        id=starting_id,
        feed=feed,
        user=user,
        role='OWNER_PLUS'
    )
    DBSession.add_all([feed_template, feed, feed_user])
    data_stream_templates = [
        DataStreamTemplate(
            id=starting_id,
            feed_template=feed_template,
            name='Outdoor temperature (BT1)',
            label='outdoor_temp',
            measurement_unit=u'°C',
            writable=False,
            modbus_register_type='HOLDING',
            modbus_slave=1,
            modbus_address=40004,
            modbus_count=1
        ),
        DataStreamTemplate(
            id=starting_id + 1,
            feed_template=feed_template,
            name='Flow temperature (BT2)',
            label='flow_temp',
            measurement_unit=u'°C',
            writable=False,
            modbus_register_type='HOLDING',
            modbus_slave=1,
            modbus_address=40008,
            modbus_count=1
        ),
        DataStreamTemplate(
            id=starting_id + 2,
            feed_template=feed_template,
            name='Return temperature (BT3)',
            label='return_temp',
            measurement_unit=u'°C',
            writable=False,
            modbus_register_type='HOLDING',
            modbus_slave=1,
            modbus_address=40012,
            modbus_count=1
        ),
        DataStreamTemplate(
            id=starting_id + 3,
            feed_template=feed_template,
            name='Hot water, top (BT7)',
            label='hot_water_top',
            measurement_unit='?',
            writable=False,
            modbus_register_type='HOLDING',
            modbus_slave=1,
            modbus_address=40013,
            modbus_count=1
        ),
        DataStreamTemplate(
            id=starting_id + 4,
            feed_template=feed_template,
            name='Hot water middle (BT6)',
            label='hot_water_middle',
            measurement_unit='?',
            writable=False,
            modbus_register_type='HOLDING',
            modbus_slave=1,
            modbus_address=40014,
            modbus_count=1
        ),
        DataStreamTemplate(
            id=starting_id + 5,
            feed_template=feed_template,
            name='Brine in (BT10)',
#.........这里部分代码省略.........
开发者ID:fikander,项目名称:sngtec-sngconnect,代码行数:103,代码来源:create_test_data.py

示例4: create_test_data

# 需要导入模块: from sngconnect.database import DBSession [as 别名]
# 或者: from sngconnect.database.DBSession import add_all [as 别名]
def create_test_data():
    starting_id = 100000
    feed_template = FeedTemplate(
        id=starting_id,
        name=u"Licznik prądu",
        dashboard_layout="GAUGES",
        modbus_bandwidth=9600,
        modbus_port='/dev/ttyS0',
        modbus_parity='EVEN',
        modbus_data_bits=8,
        modbus_stop_bits=1,
        modbus_timeout=5,
        modbus_endianness='BIG',
        modbus_polling_interval=120
    )
    feed = Feed(
        id=starting_id,
        template=feed_template,
        name=u"Licznik energii Saia-Burgess ALE3",
        description=u"Licznik prądu w biurze Synergii w Warszawie",
        address=u"ul. Bysławska 82 lok. 312\n04-993 Warszawa",
        latitude=52.158427,
        longitude=21.198292,
        api_key='pnqt1tgDLBbzoghjCBDrpcD2NXUCP1WGFUDwm7baQTgmgueS5eU5c4W9EpLrnorJKC4DMfKe255YbwPvAJ7ppbD21NAs8XLk4XQb',
        created=pytz.utc.localize(datetime.datetime.utcnow())
    )
    feed.regenerate_activation_code()
    user = DBSession.query(User).filter(User.email == '[email protected]').one()
    feed_user = FeedUser(
        id=starting_id,
        feed=feed,
        user=user,
        role='OWNER_PLUS'
    )
    DBSession.add_all([feed_template, feed, feed_user])
    data_stream_templates = [
        DataStreamTemplate(
            id=starting_id,
            feed_template=feed_template,
            label='t1_total',
            name='t1_total',
            measurement_unit='0.01 kWh',
            writable=False,
            modbus_register_type='HOLDING',
            modbus_slave=1,
            modbus_address=27,
            modbus_count=2,
            show_on_dashboard=True,
            default_minimum=0,
            default_maximum=100,
        ),
        DataStreamTemplate(
            id=starting_id + 1,
            feed_template=feed_template,
            label='t2_total',
            name='t2_total',
            measurement_unit='0.01 kWh',
            writable=False,
            modbus_register_type='HOLDING',
            modbus_slave=1,
            modbus_address=31,
            modbus_count=2,
            show_on_dashboard=True,
            default_minimum=0,
            default_maximum=100,
        ),
        DataStreamTemplate(
            id=starting_id + 2,
            feed_template=feed_template,
            label='baud',
            name='baud',
            measurement_unit='baud',
            writable=False,
            modbus_register_type='HOLDING',
            modbus_slave=1,
            modbus_address=2,
            modbus_count=2
        ),
        DataStreamTemplate(
            id=starting_id + 3,
            feed_template=feed_template,
            label='version',
            name='version',
            measurement_unit='.',
            writable=False,
            modbus_register_type='HOLDING',
            modbus_slave=1,
            modbus_address=0,
            modbus_count=1
        ),
        DataStreamTemplate(
            id=starting_id + 4,
            feed_template=feed_template,
            label='phase1_URMS',
            name='phase1_URMS',
            measurement_unit='V',
            writable=False,
            modbus_register_type='HOLDING',
            modbus_slave=1,
            modbus_address=35,
#.........这里部分代码省略.........
开发者ID:fikander,项目名称:sngtec-sngconnect,代码行数:103,代码来源:create_test_data.py


注:本文中的sngconnect.database.DBSession.add_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。