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


Python SIMSConn.fetchone方法代码示例

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


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

示例1: find_emplid

# 需要导入模块: from coredata.queries import SIMSConn [as 别名]
# 或者: from coredata.queries.SIMSConn import fetchone [as 别名]
def find_emplid(userid):
    """
    Find emplid from userid by looking at email addresses: incorrect in general but works for the few people needed here.
    """
    db = SIMSConn()
    db.execute("""SELECT emplid FROM ps_email_addresses WHERE email_addr=%s""", (userid+'@sfu.ca',))
    return db.fetchone()[0]
开发者ID:tedkirkpatrick,项目名称:coursys,代码行数:9,代码来源:devtest_importer.py

示例2: guess_userid

# 需要导入模块: from coredata.queries import SIMSConn [as 别名]
# 或者: from coredata.queries.SIMSConn import fetchone [as 别名]
def guess_userid(emplid):
    """
    Find userid from emplid by looking at email addresses: incorrect in general but works enough for some test data.
    """
    db = SIMSConn()
    db.execute("""SELECT email_addr FROM ps_email_addresses WHERE emplid=%s AND email_addr LIKE '%%@sfu.ca %%'""", (emplid,))
    row = db.fetchone()
    if row:
        email = row[0]
        return email[:-7]
开发者ID:tedkirkpatrick,项目名称:coursys,代码行数:12,代码来源:devtest_importer.py

示例3: main

# 需要导入模块: from coredata.queries import SIMSConn [as 别名]
# 或者: from coredata.queries.SIMSConn import fetchone [as 别名]
def main():
    db = SIMSConn()
    out = csv.writer(open(acad_plan+".csv", 'wb'))
    out.writerow(['Emplid', 'Name', 'Attempted Cred', 'As Of', 'CGPA'])
    
    query = "SELECT ap.emplid " \
            "FROM ps_acad_plan ap " \
            "WHERE ap.acad_plan=%s " \
            "GROUP BY ap.emplid ORDER BY ap.emplid"
    db.execute(query, (acad_plan,))
    all_emplids = [row[0] for row in list(db)]
    #all_emplids = all_emplids[:30]
    count = 0
    
    for emplid in all_emplids:
        query = "SELECT ap.stdnt_car_nbr " \
                "FROM ps_acad_plan ap, " + max_effdt + " as maxeffdt " \
                "WHERE maxeffdt.emplid=ap.emplid " \
                " AND maxeffdt.stdnt_car_nbr=ap.stdnt_car_nbr" \
                " AND ap.effdt=maxeffdt.effdt AND ap.acad_plan=%s " \
                "GROUP BY ap.stdnt_car_nbr"
        db.execute(query, (emplid,acad_plan))
        
        #print emplid, list(db)
        
        for (car_nbr,) in list(db):
            query = "SELECT ct.cum_gpa, ct.strm, ct.tot_taken_gpa, pd.name " \
                    "FROM ps_stdnt_car_term ct, ps_personal_data pd " \
                    "WHERE ct.emplid=pd.emplid AND ct.emplid=%s " \
                    " AND stdnt_car_nbr=%s " \
                    " AND tot_taken_gpa>0 " \
                    "ORDER BY strm DESC FETCH FIRST 1 ROWS ONLY"
            db.execute(query, (emplid,car_nbr))
            row = db.fetchone()
            #print emplid, car_nbr, row
            if not row:
                continue
            gpa, strm, taken, name = row
            out.writerow([emplid, name, taken, strm, gpa])
            count += 1
    
    out.writerow(['Average', None, None, None, "=AVERAGE(E2:E%i)"%(count+1)])
开发者ID:avacariu,项目名称:coursys,代码行数:44,代码来源:zuquery.py

示例4: get_unit

# 需要导入模块: from coredata.queries import SIMSConn [as 别名]
# 或者: from coredata.queries.SIMSConn import fetchone [as 别名]
def get_unit(acad_org, create=False):
    """
    Get the corresponding Unit
    """
    # there are some inconsistent acad_org values: normalize.
    if acad_org == 'GERON':
        acad_org = 'GERONTOL'
    elif acad_org == 'GEOG':
        acad_org = 'GEOGRAPH'
    elif acad_org == 'BUS':
        acad_org = 'BUS ADMIN'
    elif acad_org == 'HUM':
        acad_org = 'HUMANITIES'
    elif acad_org == 'EVSC':
        acad_org = 'ENVIRO SCI'

    try:
        unit = Unit.objects.get(acad_org=acad_org)
    except Unit.DoesNotExist:
        db = SIMSConn()
        db.execute("SELECT descrformal FROM ps_acad_org_tbl "
                   "WHERE eff_status='A' and acad_org=%s", (acad_org,))
        
        name, = db.fetchone()
        if acad_org == 'COMP SCI': # for test/demo imports
            label = 'CMPT'
        elif acad_org == 'ENG SCI': # for test/demo imports
            label = 'ENSC'
        elif acad_org == 'ENVIRONMEN': # for test/demo imports
            label = 'FENV'
        elif acad_org == 'DEAN GRAD': # for test/demo imports
            label = 'GRAD'
        else:
            label = acad_org[:4].strip()

        if create:
            unit = Unit(acad_org=acad_org, label=label, name=name, parent=None)
            unit.save()
        else:
            raise KeyError("Unknown unit: acad_org=%s, label~=%s, name~=%s." % (acad_org, label, name))

    return unit
开发者ID:sfu-fas,项目名称:coursys,代码行数:44,代码来源:importer.py


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