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


Python CommonUtils.getConnect方法代码示例

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


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

示例1: insertPlayer

# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import getConnect [as 别名]
def insertPlayer(players):
    insertSql = "insert into player(player_zn_name,player_eng_name,team,location,height,weight,birthday,money) " \
                "values(""?,?,?,?,?,?,?,?)"
    selectSql = "select * from player where player_eng_name = ? and birthday=?"
    updateSql = "update player set team=?,location=?,height =?,weight=?,birthday=?,money=?,player_zn_name=? where player_eng_name=? and birthday=?"

    conn = CommonUtils.getConnect()
    cu = conn.cursor()

    #cu.execute("delete from player")

    insertValues = []
    updateValues = []
    for player in players:
        # 先判断是否存在此球员
        cu.execute(selectSql, (player.playerEngName, player.birthday))
        result = cu.fetchall()
        if(len(result) == 0):
            #若不存在,则直接插入
            insertValues.append((player.playerZnName, player.playerEngName, player.teamName, player.location, player.height, player.weight, player.birthday, player.money))
        else:
            # 若存在,则直接更新即可
            updateValues.append((player.teamName,player.location,player.height,player.weight,player.birthday,player.money,player.playerZnName,player.playerEngName,player.birthday))

    # before insert,delete data that is older
    #cu.execute("delete from player")
    # insert player data
    print "新增数据" + str(len(insertValues))
    print "更新数据" + str(len(updateValues))
    cu.executemany(insertSql,insertValues)
    cu.executemany(updateSql,updateValues)
    conn.commit()
    conn.close()
开发者ID:jinkingmanager,项目名称:my_python_code,代码行数:35,代码来源:DAO.py

示例2: insertSchedules

# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import getConnect [as 别名]
def insertSchedules(schedules):
	insertSql = "insert into point(type,date,time,weekday,guest,home) values (?,?,?,?,?,?)"

	insertValus = []
	for point in schedules:
		schedule = (point.type,point.date,point.time,point.weekday,point.guest,point.home)
		insertValus.append(schedule)

	conn = CommonUtils.getConnect()
	cu = conn.cursor()
	cu.execute("delete from point")
	cu.executemany(insertSql,insertValus)
	conn.commit()
	conn.close()
开发者ID:jinkingmanager,项目名称:my_python_code,代码行数:16,代码来源:DAO.py

示例3: insertTeam

# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import getConnect [as 别名]
def insertTeam(teams):
    insertSql = "insert into team(eng_name,chinese_name,city,short_name) values(?,?,?,?)"

    insertValues = []
    for team in teams:
        value = (team.engName, team.chineseName, team.city, team.shortName)
        insertValues.append(value)

    conn = CommonUtils.getConnect()
    cu = conn.cursor()
    cu.execute("delete from team")
    cu.executemany(insertSql, insertValues)
    conn.commit()
    conn.close()
开发者ID:jinkingmanager,项目名称:my_python_code,代码行数:16,代码来源:DAO.py


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