<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 數據庫 !
    呵呵   回復  更多評論
      

    主站蜘蛛池模板: 国内精自视频品线六区免费| 日本二区免费一片黄2019| 91嫩草亚洲精品| 日韩午夜免费视频| 国产日韩AV免费无码一区二区 | 久久青草91免费观看| 亚洲人成人网毛片在线播放| 久久亚洲av无码精品浪潮| www视频免费看| 一级毛片a免费播放王色电影 | 最近免费最新高清中文字幕韩国| 亚洲乱码国产乱码精华| 亚洲成AV人片在线观看WWW| 好男人看视频免费2019中文| 青柠影视在线观看免费高清| 亚洲欧美第一成人网站7777| 亚洲成AV人片在| 亚洲av无码成人精品区| 精品无码免费专区毛片| 一级毛片aa高清免费观看| 亚洲伊人久久大香线蕉结合| 亚洲女久久久噜噜噜熟女| 日本大片在线看黄a∨免费| 免费看又黄又无码的网站| 免费的黄网站男人的天堂| 77777午夜亚洲| 亚洲视频网站在线观看| 中文字幕在线亚洲精品| 日韩一区二区在线免费观看| 色播精品免费小视频| 久久国产免费一区二区三区| yy一级毛片免费视频| 亚洲av色香蕉一区二区三区蜜桃| 亚洲高清日韩精品第一区| 亚洲精品狼友在线播放| 亚洲成AⅤ人影院在线观看| 免费无码精品黄AV电影| 99久久99久久精品免费看蜜桃 | 精品多毛少妇人妻AV免费久久| 亚洲综合色一区二区三区| 亚洲视频中文字幕在线|