本文整理汇总了Python中scatterbrainz.model.meta.Session.add_all方法的典型用法代码示例。如果您正苦于以下问题:Python Session.add_all方法的具体用法?Python Session.add_all怎么用?Python Session.add_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scatterbrainz.model.meta.Session
的用法示例。
在下文中一共展示了Session.add_all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_app
# 需要导入模块: from scatterbrainz.model.meta import Session [as 别名]
# 或者: from scatterbrainz.model.meta.Session import add_all [as 别名]
def setup_app(command, conf, vars):
"""Place any commands to setup scatterbrainz here"""
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
log.info("Creating tables")
meta.metadata.create_all(bind=meta.engine)
log.info("Tables created")
session = Session()
session.begin()
loginPerm = Permission()
loginPerm.permission_name = u'login'
adminPerm = Permission()
adminPerm.permission_name = u'admin'
adminGroup = Group()
adminGroup.group_name = u'admins'
adminGroup.permissions = [loginPerm, adminPerm]
userGroup = Group()
userGroup.group_name = u'users'
userGroup.permissions = [loginPerm]
admin = User()
admin.user_name = u'admin'
admin.password = u'default'
admin.who = u'admin'
admin.registered = datetime.now()
admin.groups = [adminGroup]
session.add_all([loginPerm, adminPerm, adminGroup, userGroup, admin])
session.commit()