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


Python DBSession.connection方法代码示例

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


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

示例1: getUserInfo

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import connection [as 别名]
def getUserInfo(userid):
    mySession = DBSession()

    sql = "SELECT user_fullname, user_organization, user_email, user_about,lkpcountry.cnty_name,lkpsector.sector_name FROM " \
          "user,lkpcountry,lkpsector WHERE user_cnty = lkpcountry.cnty_cod AND user_sector = lkpsector.sector_cod AND user_name = " + "'" + userid + "'"

    connection = mySession.connection()
    results = connection.execute(sql)

    userInfo = {}
    for result in results:
        userInfo["user_fullname"] = result[0];
        userInfo["user_organization"] = result[1];
        userInfo["user_email"] = result[2];
        userInfo["user_about"] = result[3];
        userInfo["cnty_name"] = result[4];
        userInfo["sector_name"] = result[5];
    connection.close()
    mySession.close()
    return userInfo
开发者ID:BioversityCostaRica,项目名称:CLIMMOBNET_V3,代码行数:22,代码来源:dbuserfunctions.py

示例2: getUserLog

# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import connection [as 别名]
def getUserLog(user,limit = True):
    sql = "SELECT DATE_FORMAT(DATE(log_datetime), '%%W %%D %%M %%Y') as log_date,TIME(log_datetime) as log_time,log_type,log_message,log_datetime as date1,log_datetime as date2 FROM activitylog WHERE log_user = '" + user + "' ORDER BY date1 DESC,date2 ASC,log_id desc"
    if limit:
        sql = sql + " LIMIT 20"
    mySession = DBSession()
    connection = mySession.connection()
    activities = connection.execute(sql)
    items = []
    count = 1
    for activity in activities:
        if count%2 == 0:
            alt = False
        else:
            alt= True
        count = count + 1
        if activity[2] == "PRF":
            color = "terques"
            icon = "fa-user"
        else:
            if activity[2] == "MOD":
                color = "purple"
                icon = "fa-gears"
            else:
                if activity[2] == "FED":
                    color = "blue"
                    icon = "fa-leaf"
                else:
                    if activity[2] == "API":
                        color = "green"
                        icon = "fa-bolt"
                    else:
                        color = "red"
                        icon = "fa-bullhorn"

        items.append({"date":activity[0],"time":activity[1],"type":activity[2],"message":activity[3],"alt":alt,"icon":icon,"color":color})
    connection.close()
    mySession.close()
    return items
开发者ID:BioversityCostaRica,项目名称:CLIMMOBNET_V3,代码行数:40,代码来源:dbuserfunctions.py


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