本文整理汇总了Python中comcenter.model.DBSession类的典型用法代码示例。如果您正苦于以下问题:Python DBSession类的具体用法?Python DBSession怎么用?Python DBSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DBSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: serviceShowByClub
def serviceShowByClub(cls,seniorclub=None,fiscalyear=None ):
sql = text("""SELECT
dental_senior_club_kpi.dental_senior_club_kpi_id,
dental_senior_club_kpi.detail,
dental_senior_club_kpi.`range`,
senior_service.dental_senior_club_service_id,
senior_service.fiscal_year,
senior_service.senior_club_id,
IFNULL( senior_service.`value`, 0) as value
FROM
dental_senior_club_kpi LEFT JOIN
(
SELECT
senior_club.senior_club_id,
senior_club.senior_club_name,
dental_senior_club_service.fiscal_year,
dental_senior_club_service.`value`,
dental_senior_club_service.dental_senior_club_service_id,
dental_senior_club_service.dental_senior_club_kpi_id
from
senior_club LEFT JOIN dental_senior_club_service on senior_club.senior_club_id = dental_senior_club_service.senior_club_id
WHERE
dental_senior_club_service.fiscal_year=:fiscal_year and
senior_club.senior_club_id=:seniorclub
) senior_service on dental_senior_club_kpi.dental_senior_club_kpi_id = senior_service.dental_senior_club_kpi_id
""" , bindparams=[bindparam('seniorclub', str(seniorclub)),bindparam('fiscal_year', str(fiscalyear)) ] );
#log.info(sql);
result = DBSession.execute(sql );
return result ; #DBSession.query(cls).filter(sql).all();
示例2: serviceShowBySchoolandGroupKPI
def serviceShowBySchoolandGroupKPI(cls,school=None,fiscalyear=None,groupKPI=None):
sql = text("""SELECT
dental_school_kpi.dental_school_kpi_id,
dental_school_kpi.dental_school_kpi_group_id,
dental_school_kpi.detail,
dental_school_kpi.`range`,
service.dental_school_service_id,
service.fiscal_year,
service.school_id,
IFNULL(service.`value`,0) as value
from
dental_school_kpi LEFT JOIN (
select
dental_school_service.dental_school_service_id,
dental_school_service.fiscal_year,
dental_school_service.school_id,
dental_school_service.`value` ,
dental_school_service.dental_school_kpi_id
from
school JOIN dental_school_service on school.school_id = dental_school_service.school_id
WHERE
school.school_id=:schoolid and dental_school_service.fiscal_year=:fiscal_year
) service on service.dental_school_kpi_id = dental_school_kpi.dental_school_kpi_id
WHERE
dental_school_kpi.dental_school_kpi_group_id=:groupkpi """ , bindparams=[bindparam('schoolid', str(school)),bindparam('fiscal_year', str(fiscalyear)) ,bindparam('groupkpi', str(groupKPI)) ] );
#log.info(sql);
result = DBSession.execute(sql );
return result ; #DBSession.query(cls).filter(sql).all();
示例3: serviceShowByChildDevCenter
def serviceShowByChildDevCenter(cls,childcenter=None,fiscalyear=None ):
sql = text("""select
dental_child_dev_center_kpi.dental_child_dev_center_kpi_id,
dental_child_dev_center_kpi.detail,
service.child_dev_center_id,
service.dental_child_dev_center_service_id,
service.fiscal_year,
IFNULL(service.`value`,0) as value
from
dental_child_dev_center_kpi LEFT JOIN
(
select
dental_child_dev_center_service.child_dev_center_id,
dental_child_dev_center_service.dental_child_dev_center_service_id,
dental_child_dev_center_service.dental_child_dev_center_kpi_id,
dental_child_dev_center_service.fiscal_year,
dental_child_dev_center_service.`value`
FROM
child_dev_center LEFT JOIN dental_child_dev_center_service on dental_child_dev_center_service.child_dev_center_id = child_dev_center.child_dev_center_id
WHERE
dental_child_dev_center_service.fiscal_year=:fiscal_year and
child_dev_center.child_dev_center_id=:childcenter
) service on dental_child_dev_center_kpi.dental_child_dev_center_kpi_id = service.dental_child_dev_center_kpi_id
""" , bindparams=[bindparam('childcenter', str(childcenter)),bindparam('fiscal_year', str(fiscalyear)) ] );
#log.info(sql);
result = DBSession.execute(sql );
return result ; #DBSession.query(cls).filter(sql).all();
示例4: listGroupUser
def listGroupUser(self,**kw):
groups = DBSession.query(Group).all();
self.listgroup = [];
for group in groups:
self.listgroup.append({'id' : group.group_id ,
'name' : group.group_name
});
return dict(root = self.listgroup,total=str(len(self.listgroup)));
示例5: showProgramClinicReport
def showProgramClinicReport(cls,startDate, stopDate,book_type,bookSearch,offset=0,limit=15):
query = DBSession.query(cls).filter( and_( cls.activate == '1', and_( cls.book_detail.like(bookSearch) ,and_( cls.book_type_id == book_type ,cls.book_recive.between(startDate, stopDate) ) )) );
count = query.count();
list = query.order_by(desc(cls.book_number)).limit(limit).offset(offset).all();
#DBSession.query(cls).filter(between(cls.book_recive, startDate, stopDate)).all();
print count ;
return count, list;
示例6: search
def search(cls,fiscalyear = None, group= None, subgroup= None):
sql = "1=1 ";
if (fiscalyear):
sql = sql + " and fiscal_year = " + fiscalyear;
if(group):
sql = sql + " and revenue_list_id = " + group;
if(subgroup):
sql = sql + " and revenue_sub_list_id = " + subgroup;
log.info(sql);
return DBSession.query(cls).filter(sql).all();
示例7: serviceShowAllKPIBySenior
def serviceShowAllKPIBySenior(cls,fiscalyear=None):
sql = text ("""
SELECT
senior_club.senior_club_id,
senior_club.senior_club_name,
(SELECT value from dental_senior_club_service where fiscal_year =:fiscal_year1 and dental_senior_club_kpi_id = 2 and senior_club_id = senior_club.senior_club_id ) as kpi1,
(SELECT value from dental_senior_club_service where fiscal_year =:fiscal_year2 and dental_senior_club_kpi_id = 3 and senior_club_id = senior_club.senior_club_id ) as kpi2,
(SELECT value from dental_senior_club_service where fiscal_year =:fiscal_year3 and dental_senior_club_kpi_id = 4 and senior_club_id = senior_club.senior_club_id ) as kpi3
FROM
senior_club
""", bindparams=[bindparam('fiscal_year1', str(fiscalyear)),bindparam('fiscal_year2', str(fiscalyear)),bindparam('fiscal_year3', str(fiscalyear)) ]);
result = DBSession.execute(sql );
return result ;
示例8: querySummary
def querySummary(cls,fiscalyear=None,division=None,section=None,status=None,projectType=None,start=0,limit=25):
sql = "where 1=1 ";
if (fiscalyear):
sql = sql + " and project.fiscal_year = " + fiscalyear;
if(projectType):
sql = sql + " and project_type_id = " + projectType;
if(division):
sql = sql + " and project.division_id = " + division;
if(section):
sql = sql + " and project.section_id = " + section;
if(status):
sql = sql + " and project.project_status_id = " + status ;
sql = text("""select
d.description as division ,
sum( d.allbudget) as allbudget,
sum( d.budget) as budget,
sum( d.maintenance_funds_budget) as maintenance_funds_budget,
sum( d.budget_other_from) as budget_other_from
FROM
(
select
division.description,
IFNULL(project.budget, 0) + IFNULL(project.maintenance_funds_budget,0) +IFNULL(project.budget_other_from ,0) as allbudget,
IFNULL(project.budget, 0) as budget,
IFNULL(project.maintenance_funds_budget,0) as maintenance_funds_budget,
IFNULL(project.budget_other_from ,0) as budget_other_from
from division left join project on division.division_id = project.division_id """ + sql +
""" ) d
group by d.description """);
result = DBSession.execute(sql);
list = [];
for row in result:
list.append({ 'division':row['division'],
'allBudget' :row['allbudget'] ,
'budget' :row['budget'] ,
'maintenance_funds_budget' :row['maintenance_funds_budget'] ,
'budget_other_from' :row['budget_other_from'],
u'งบประมาณ' :row['budget'] ,
u'งบประมาณอื่น' :row['budget_other_from'] ,
u'เงินบำรุง' :row['maintenance_funds_budget']
});
return list;
示例9: serviceShoAllKPIByChildDevCenter
def serviceShoAllKPIByChildDevCenter(cls,fiscalyear=None):
sql = text("""
select
child_dev.child_dev_center_id,
child_dev.child_dev_name,
( select value from dental_child_dev_center_service where fiscal_year =:fiscal_year1 and dental_child_dev_center_kpi_id =1 and dental_child_dev_center_service.child_dev_center_id = child_dev.child_dev_center_id) as kpi1,
( select value from dental_child_dev_center_service where fiscal_year =:fiscal_year2 and dental_child_dev_center_kpi_id =2 and dental_child_dev_center_service.child_dev_center_id = child_dev.child_dev_center_id) as kpi2
from
child_dev_center as child_dev
ORDER BY
child_dev.child_dev_center_id
""" , bindparams=[bindparam('fiscal_year1', str(fiscalyear)) ,bindparam('fiscal_year2', str(fiscalyear)) ]);
result = DBSession.execute(sql );
return result ;
示例10: listUser
def listUser(self,**kw):
#users = DBSession.query(User).all();
groups = DBSession.query(Group).all();
self.list = [];
for group in groups:
for guser in group.users:
self.list.append({'id' : guser.user_id ,
'name' : guser.user_name,
'display' : guser.display_name,
'email' : guser.email_address,
'group_id' : group.group_id,
'group' : group.group_name
});
return dict(root = self.list,total=str(len(self.list)));
示例11: search
def search(cls,fiscalyear=None,division=None,section=None,status=None,projectType=None,start=0,limit=25):
sql = "1=1 ";
if (fiscalyear):
sql = sql + " and fiscal_year = " + fiscalyear;
if(projectType):
sql = sql + " and project_type_id = " + projectType;
if(division):
sql = sql + " and division_id = " + division;
if(section):
sql = sql + " and section_id = " + section;
if(status):
sql = sql + " and project_status_id = " + status ;
log.info(sql);
return DBSession.query(cls).filter(sql).all();
示例12: serviceShoAllKPIBySchool
def serviceShoAllKPIBySchool(cls,fiscalyear=None):
sql = text("""
select
school.school_id,
school.school_name,
( SELECT value from dental_school_service where fiscal_year=:fiscal_year1 and dental_school_kpi_id = 2 and dental_school_service.school_id = school.school_id) as kpi1,
( SELECT value from dental_school_service where fiscal_year=:fiscal_year2 and dental_school_kpi_id = 3 and dental_school_service.school_id = school.school_id) as kpi2,
( SELECT value from dental_school_service where fiscal_year=:fiscal_year3 and dental_school_kpi_id = 4 and dental_school_service.school_id = school.school_id) as kpi3,
( SELECT value from dental_school_service where fiscal_year=:fiscal_year4 and dental_school_kpi_id = 9 and dental_school_service.school_id = school.school_id) as kpi4
from
school
WHERE
school.high_school = 0
ORDER BY
school.school_id
""", bindparams=[ bindparam('fiscal_year1', str(fiscalyear)),bindparam('fiscal_year2', str(fiscalyear)),bindparam('fiscal_year3', str(fiscalyear)),bindparam('fiscal_year4', str(fiscalyear)) ]);
result = DBSession.execute(sql );
return result ;
示例13: setUp
def setUp(self):
"""Prepare model test fixture."""
try:
new_attrs = {}
new_attrs.update(self.attrs)
new_attrs.update(self.do_get_dependencies())
self.obj = self.klass(**new_attrs)
DBSession.add(self.obj)
DBSession.flush()
return self.obj
except:
DBSession.rollback()
raise
示例14: listIndicatorBySection
def listIndicatorBySection(cls,sectionid=None,year=None,start_year=None,month=None):
list =[];
if(sectionid ):
sql = text("""select
id.indicators_detail_id,
id.detail,
ty.target,
rs.risk_section_id,
rs.description,
ids.indicators_service_id,
ids.indicator_value,
ids.months_id,
ty.years_id
from
indicators_detail id
LEFT JOIN target_year ty on id.indicators_detail_id = ty.indicators_detail_id
LEFT JOIN map_indicators_section mis on id.indicators_detail_id = mis.indicators_detail_id
LEFT JOIN risk_section rs on rs.risk_section_id = mis.risk_section_id
LEFT OUTER JOIN indicators_service ids on (ids.indicators_detail_id = id.indicators_detail_id
and ids.risk_section_id =rs.risk_section_id and ids.years_id = ty.years_id and ids.months_id = """ + str(month) +""" )
where
ty.active = 1
and ty.years_id = """ + str(year) + """
and rs.risk_section_id = """ + str(sectionid) + """
""");
result = DBSession.execute(sql);
for row in result:
list.append({ 'id' : row['indicators_detail_id'] ,
'indicators_detail_id' : row['indicators_detail_id'] ,
'indicators_service_id' : row['indicators_service_id'],
'detail' : row['detail'] ,
'target' : row['target'] ,
'risk_section_id' : row['risk_section_id'] ,
'indicator_value' : row['indicator_value'] ,
'months_id' : row['months_id'] ,
'years_id' : row['years_id'] });
return list;
示例15: queryGroupByFiscalYear
def queryGroupByFiscalYear(cls,year,revenue_list= '%'):
sql = text("""select
main.revenue_list_name,
main.revenue_sub_list_name,
IFNULL(revenue_year.estimate,0) as estimate,
IFNULL(revenue_year.fiscal_year,:show_year ) as fiscal_year,
main.revenue_list_id,
main.revenue_sub_list_id
from
(
select
revenue_list.revenue_list_id,
revenue_list.revenue_list_name,
revenue_sub_list.revenue_sub_list_id,
revenue_sub_list.revenue_sub_list_name
from
revenue_sub_list inner join revenue_list on revenue_sub_list.revenue_list_id = revenue_list.revenue_list_id
) as main
left join (
SELECT
revenue.estimate,
revenue.fiscal_year,
revenue.revenue_list_id,
revenue.revenue_sub_list_id
from
revenue
where revenue.fiscal_year=:fiscal_year
) revenue_year
on ( main.revenue_list_id = revenue_year.revenue_list_id and main.revenue_sub_list_id = revenue_year.revenue_sub_list_id)
where
main.revenue_list_id like :revenue_list_id
ORDER BY
main.revenue_list_id,
main.revenue_sub_list_id """ , bindparams=[bindparam('show_year', str(year)),bindparam('fiscal_year', str(year)), bindparam('revenue_list_id',str(revenue_list))] );
#log.info(sql);
result = DBSession.execute(sql );
return result ; #DBSession.query(cls).filter(sql).all();