<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Skynet

    ---------- ---------- 我的新 blog : liukaiyi.cublog.cn ---------- ----------

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      112 Posts :: 1 Stories :: 49 Comments :: 0 Trackbacks



    #!/usr/bin/python
    #
    coding=UTF-8
    #
    sql 參考
    #
    http://www.kitebird.com/articles/pydbapi.html
    import cx_Oracle
    import re,os,sys

    logTxt
    ="./log"

    dataFile 
    = "./data.txt"
    fileCharset 
    = "GBK"
    dbCharset 
    = "GBK"

    username 
    = "...."
    userpwd 
    = "...."
    host 
    ="...."
    dbname
    ="...."
    #dbname="..."

    MuById_SQL
    ="select count(*) from mn00_tbl_music tm where tm.id=:mid"

    CRById_SQL
    ="select tc.music_id from mn05_tbl_copyright tc where tc.copyright_id=:crid"
    CRById_In_Music_SQL
    ="update  mn05_tbl_copyright  set music_id=:mid where copyright_id=:crid"

    CRByMNameAndAName_SQL
    =" select tc.copyright_id from mn05_tbl_copyright tc where  (tc.actor_src_name=':acName' and tc.music_src_name=':muName' ) or (tc.actor_name=':acName' and tc.music_name=':muName') ";


    # 60056601146|失意酒(童安格)|失意酒(童安格)|10030149
    #
     CRID | 編輯后歌曲(歌手)|歌曲(歌手) |MID
    def action(strs):
        result 
    = selectSql( subSql(MuById_SQL, "mid", strs[3]) )
        
    if( int(result[0][0])>0):
            actionCR(strs[0],strs[
    3])
        
    if( strs[1and strs[1]!="" ):
            actionName(strs[
    1],strs[3])
        
    if( strs[2and strs[2]!="" ):
            actionName(strs[
    2],strs[3])


    def actionName(mu_ac,mid):
        p 
    = re.compile("(.*)\((.*)\)")
        m 
    = p.match( mu_ac )
        
    if(m):
            crmaSql
    =subSql(CRByMNameAndAName_SQL,"muName", m.group(1))
            crmaSql
    =subSql(crmaSql,"acName",m.group(2))
            
    for row in selectSql( crmaSql ):
                actionCR(row[0].
    __str__() ,mid)
            
    #count = cursor.rowcount
        
    def actionCR(crid,mid):
        result 
    = selectSql( subSql(CRById_SQL, "crid", crid )  ) 
        
    if( result[0][0]==None or int(result[0][0])==0):
            upCr
    =subSql(CRById_In_Music_SQL,"crid",crid)
            upCr
    =subSql(upCr,"mid",mid)
            
    if(execSql(upCr)>0):
                _log(
    'match crid='+crid+' muid='+mid)
    def subSql(strSql,subName,subValue):
        p 
    = re.compile(":"+subName)
        
    return p.sub( subValue, strSql)
                
    def selectSql(sql):
        
    print 'select='+sql
        cursor.execute(sql.encode(dbCharset))
        
    return cursor.fetchall()

    def execSql(sql):
        
    print 'exec='+sql
        cursor.execute(sql.encode(dbCharset))
        connection.commit()
        
    return cursor.rowcount

    def _log(show):
        
    print show
        log 
    = 'echo '+show+' >> '+logTxt
        os.system(log)
        
        
    try:
        connStr
    =username+"/"+userpwd+"@"+dbname
        
    print connStr
        connection 
    = cx_Oracle.connect(connStr) 
        cursor 
    = connection.cursor()
        file 
    = open(dataFile)
        
    if(len(sys.argv)==2):
            startRow
    =int(sys.argv[1])
        
    else:
            startRow
    =1
        row 
    = 1
        
    for str in file.readlines():
            
    if(row>=startRow):
                str 
    = re.compile("\n").sub( "", str )
                strs 
    = unicode(str, fileCharset).split("|")
                _log(
    'start row='+row.__str__()+' crid='+strs[0]+' muid='+strs[3])
                
    try:
                    action(strs)
                
    except:
                    _log(
    'err row='+row.__str__())
                _log(
    'end row='+row.__str__()+' crid='+strs[0]+' muid='+strs[3])
            row
    +=1
    finally:
        file.close()
        cursor.close()
        connection.close()   







    整理 m.tkk7.com/Good-Game
    posted on 2008-12-04 18:47 劉凱毅 閱讀(1266) 評論(2)  編輯  收藏 所屬分類: python

    Feedback

    # re: py 數據庫 2008-12-04 20:39 lexus
    沒明白什么意思,能說說嗎?  回復  更多評論
      

    # re: py 數據庫 2008-12-04 22:56 劉凱毅
    阿 對不起
    自己為了 留個記錄 python 連 oracle 數據庫 !
    呵呵   回復  更多評論
      

    主站蜘蛛池模板: 亚洲中文字幕无码不卡电影| 久久综合亚洲色HEZYO社区 | 亚洲一区二区三区免费观看| 在线观看无码的免费网站| 亚洲精品第一国产综合境外资源 | 亚洲色婷婷六月亚洲婷婷6月| 亚洲明星合成图综合区在线| 四虎精品免费永久免费视频| 两性刺激生活片免费视频| 中文字幕亚洲日韩无线码| 亚洲国产精品一区二区三区在线观看| 一级毛片a女人刺激视频免费| 青娱乐免费视频在线观看| 亚洲午夜精品一区二区公牛电影院| 一级毛片a免费播放王色电影 | 极品美女一级毛片免费| 男男AV纯肉无码免费播放无码| 图图资源网亚洲综合网站| 国产精品高清免费网站| 日韩免费无码一区二区视频| 亚洲国色天香视频| 好吊妞在线成人免费| 青娱乐在线视频免费观看| 日韩精品视频免费网址| 免费无毒a网站在线观看| 亚洲精品国产成人片| 三年片免费高清版 | 亚洲日本韩国在线| 色噜噜狠狠色综合免费视频| 91麻豆国产自产在线观看亚洲| 亚洲免费在线视频| 亚洲欧洲日产国产综合网| 国产一区二区三区免费| 亚洲精品美女久久久久99| 成人免费观看一区二区| 亚洲人成影院在线高清| 免费中文字幕在线| 免费人成大片在线观看播放电影| 自拍偷自拍亚洲精品第1页| 久久精品免费一区二区| 免费人成视频在线观看免费|