本文整理汇总了Python中argonaut.model.meta.Session.query方法的典型用法代码示例。如果您正苦于以下问题:Python Session.query方法的具体用法?Python Session.query怎么用?Python Session.query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类argonaut.model.meta.Session
的用法示例。
在下文中一共展示了Session.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def get(id, active_only=True):
try:
if active_only:
return Session.query(Post).filter(Post.status == 1).filter(Post.id == id).first()
else:
return Session.query(Post).get(id)
except TypeError:
return None
示例2: init_data
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def init_data():
print "Initing auth data"
query = Session.query(User)
for rec in user_values:
if not query.get(unicode(rec[0])):
user = User()
user.username = unicode(rec[1])
user.email = unicode(rec[2])
user._set_password(unicode(rec[3]))
user.name = unicode(rec[4])
Session.add(user)
Session.commit()
query = Session.query(Group)
for rec in group_values:
if not query.get(unicode(rec[0])):
group = Group()
group.name = unicode(rec[1])
Session.add(group)
Session.commit()
query = Session.query(Permission)
for rec in permission_values:
if not query.get(unicode(rec[0])):
permission = Permission()
permission.name = unicode(rec[1])
Session.add(permission)
Session.commit()
query = Session.query(User_Group)
for rec in user_group_values:
if not query.get(unicode(rec[0])):
user_group = User_Group()
user_group.user_id = unicode(rec[1])
user_group.group_id = unicode(rec[2])
Session.add(user_group)
Session.commit()
query = Session.query(Group_Permission)
for rec in group_permission_values:
if not query.get(unicode(rec[0])):
group_permission = Group_Permission()
group_permission.group_id = unicode(rec[1])
group_permission.permission_id = unicode(rec[2])
Session.add(group_permission)
Session.commit()
示例3: get_url
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def get_url(id, url_param):
route = Session.query(Page_Type).get(id)
if url_param:
target = url(controller=route.controller, action=route.action, id=url_param)
elif len(route.param) > 0:
target = url(controller=route.controller, action=route.action, id=route.param)
else:
target = url(controller=route.controller, action=route.action)
return target
示例4: init_data
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def init_data():
print "Initing box data"
query = Session.query(Box)
for rec in values:
if not query.get(rec[0]):
item = Box()
item.name = unicode(rec[1])
item.template = unicode(rec[2])
Session.add(item)
Session.commit()
示例5: init_data
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def init_data():
print "Initing config data"
query = Session.query(Config)
for rec in values:
if not query.get(unicode(rec[0])):
config = Config()
config.id = unicode(rec[0])
config.value = unicode(rec[1])
Session.add(config)
Session.commit()
示例6: init_data
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def init_data():
print "Initing media data"
query = Session.query(Media)
for rec in values:
if not query.get(rec[0]):
media = Media()
media.id = rec[0]
media.name = unicode(rec[1])
media.url = unicode(rec[2])
Session.add(media)
Session.commit()
示例7: init_data
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def init_data():
print "Initing boxes data"
query = Session.query(Boxes)
for rec in values:
if not query.get(rec[0]):
item = Boxes()
item.box_id = rec[1]
item.status = rec[2]
item.order = rec[3]
Session.add(item)
Session.commit()
示例8: init_data
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def init_data():
print "Initing page_type data"
query = Session.query(Page_Type)
for rec in values:
if not query.get(rec[0]):
page_type = Page_Type()
page_type.id = rec[0]
page_type.name = unicode(rec[1])
page_type.controller = unicode(rec[2])
page_type.action = unicode(rec[3])
page_type.param = unicode(rec[4])
Session.add(page_type)
Session.commit()
示例9: init_data
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def init_data():
print "Initing social data"
query = Session.query(Social)
for rec in values:
if not query.get(rec[0]):
social = Social()
social.id = rec[0]
social.name = unicode(rec[1])
social.status = rec[2]
social.priority = rec[3]
social.url = unicode(rec[4])
social.media_id = rec[5]
Session.add(social)
Session.commit()
示例10: init_data
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def init_data():
print "Initing page data"
query = Session.query(Page)
for rec in values:
if not query.get(rec[0]):
page = Page()
page.id = rec[0]
page.name = unicode(rec[1])
page.status = rec[2]
page.page_order = rec[3]
page.url = unicode(rec[4])
page.type = rec[5]
Session.add(page)
Session.commit()
示例11: get_many
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def get_many(amount=10, order='asc', active_only=True, count_only=False, filter=None):
try:
query = Session.query(Post)
if active_only:
query = query.filter(Post.status == 1)
if filter:
query = query.filter(or_(Post.subject.like('%'+filter+'%'),Post.body.like('%'+filter+'%')))
if count_only:
return query.limit(amount).count()
else:
if order == 'desc':
return query.order_by(Post.id.desc()).limit(amount)
else:
return query.order_by(Post.id.asc()).limit(amount)
except Exception:
return None
示例12: get_url
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def get_url(id):
return Session.query(Media).get(id).url
示例13: get_first
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def get_first():
return Session.query(Media).first()
示例14: get_all
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def get_all():
return Session.query(Media).all()
示例15: get_name
# 需要导入模块: from argonaut.model.meta import Session [as 别名]
# 或者: from argonaut.model.meta.Session import query [as 别名]
def get_name(id):
return str(Session.query(Media).get(id).name)