當前位置: 首頁>>代碼示例>>Python>>正文


Python SyncDBMgr類代碼示例

本文整理匯總了Python中SyncDBMgr的典型用法代碼示例。如果您正苦於以下問題:Python SyncDBMgr類的具體用法?Python SyncDBMgr怎麽用?Python SyncDBMgr使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SyncDBMgr類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: insertOrUpdateRecord

def insertOrUpdateRecord(jsondata,tblName):


    for i in range(len(jsondata)):
        Id = jsondata[i]['Id']

        query ="delete from "+tblName+" where Id='"+str(Id)+"'"

        c.execute(query)

        if "BoxID" in jsondata[i].keys() and "ReferenceID" in jsondata[i].keys():
            query ="delete from "+tblName+" where BoxID='"+str(jsondata[i]['BoxID'])+"'" + " and ReferenceID='"+str(jsondata[i]['ReferenceID'])+"'"
            print('Record deleted for '+tblName+' :'+str(Id))
            c.execute(query)


        query ='insert into '+tblName+'('
        cols = ''
        vals = ''
        try:
            for key in jsondata[i].keys():

                try:
                    key = key.encode('UTF-8')
                except Exception,e:
                    key = key

                value =jsondata[i][key]

                try:
                    value = value.encode('UTF-8')
                except Exception,e:
                    value = value

                try:
                    value = value.replace('"','')
                except Exception,e:
                    value = value


                #Check if it is a file to download and download it.
                if "IsActive" in jsondata[i].keys():
                    if jsondata[i]["IsActive"]==1:
                        FileMgr.CheckAndDownloadFile(key,value,0,Id)
                else:
                    FileMgr.CheckAndDownloadFile(key,value,0,Id)


                if 'Id' in key:
                    print('Record Added/Updated for '+tblName+' :'+str(value))

                if 'AlbumDetails' in key:
                    insertOrUpdateRecord(value,'AlbumDetails')
                else:
                    if 'BoxMappings' in key:
                        insertOrUpdateRecord(value,"ArticleBoxMapping")
                    else:
                        if value is not None:
                            cols = cols + key + ','
                            vals = vals +'"'+ str(value)+ '",'
開發者ID:WinjitTech,項目名稱:moovah,代碼行數:60,代碼來源:Languages.py

示例2: insertOrUpdateRecord

def insertOrUpdateRecord(jsondata, tblName, ModuleId):
    for i in range(len(jsondata)):
        Id = jsondata[i]['Id']

        query = "delete from " + tblName + " where Id='" + str(Id) + "'"

        c.execute(query)
        #	print query
        query = 'insert into ' + tblName + '('
        cols = ''
        vals = ''
        try:
            for key in jsondata[i].keys():

                try:
                    key = key.encode('UTF-8')
                except Exception, e:
                    key = key

                value = jsondata[i][key]

                try:
                    value = value.encode('UTF-8')
                except Exception, e:
                    value = value

                try:
                    value = value.replace('"', '')
                except Exception, e:
                    value = value

                if value is not None:
                    cols = cols + key + ','
                    vals = vals + '"' + str(value) + '",'
開發者ID:WinjitTech,項目名稱:moovah,代碼行數:34,代碼來源:SponsorLinking.py

示例3: insertOrUpdateRecord

def insertOrUpdateRecord(jsondata, tblName):

    for i in range(len(jsondata)):
        Id = jsondata[i]["Id"]

        query = "delete from " + tblName + " where Id='" + str(Id) + "'"

        c.execute(query)

        query = "insert into " + tblName + "("
        cols = ""
        vals = ""
        try:
            for key in jsondata[i].keys():

                try:
                    key = key.encode("UTF-8")
                except Exception, e:
                    key = key

                value = jsondata[i][key]

                try:
                    value = value.encode("UTF-8")
                except Exception, e:
                    value = value

                try:
                    value = value.replace('"', "")
                except Exception, e:
                    value = value

                if value is not None:
                    cols = cols + key + ","
                    vals = vals + '"' + str(value) + '",'
開發者ID:WinjitTech,項目名稱:moovah,代碼行數:35,代碼來源:UserTagging.py

示例4: insertOrUpdateRecord

def insertOrUpdateRecord(jsondata,tblName):

    for i in range(len(jsondata)):
        Id = jsondata[i]['Id']

        query ="delete from "+tblName+" where Id='"+str(Id)+"'"

        c.execute(query)


        query ='insert into '+tblName+'('
        cols = ''
        vals = ''
        try:
            for key in jsondata[i].keys():

                try:
                    key = key.encode('UTF-8')
                except Exception,e:
                    key = key

                value =jsondata[i][key]

                try:
                    value = value.encode('UTF-8')
                except Exception,e:
                    value = value

                try:
                    value = value.replace('"','')
                except Exception,e:
                    value = value


                if 'Id' in key:
                    print('Record Added/Updated for '+tblName+' :'+str(value))

                if 'AlbumDetails' in key:
                    insertOrUpdateRecord(value,'AlbumDetails')
                else:
                    if 'BoxMappings' in key:
                        insertOrUpdateRecord(value,"ArticleBoxMapping")
                    else:
                        if value is not None:
                            cols = cols + key + ','
                            vals = vals +'"'+ str(value)+ '",'
開發者ID:WinjitTech,項目名稱:moovah,代碼行數:46,代碼來源:SubCategory.py

示例5: insertOrUpdateRecord

def insertOrUpdateRecord(jsondata,tblName):


    for i in range(len(jsondata)):
        Id = jsondata[i]['Id']

        query ="delete from "+tblName+" where Id='"+str(Id)+"'"

        c.execute(query)

        if "BoxID" in jsondata[i].keys() and "ReferenceID" in jsondata[i].keys():
            query ="delete from "+tblName+" where BoxID='"+str(jsondata[i]['BoxID'])+"'" + " and ReferenceID='"+str(jsondata[i]['ReferenceID'])+"'"
            print('Record deleted for '+tblName+' :'+str(Id))
            c.execute(query)


        query ='insert into '+tblName+'('
        cols = ''
        vals = ''
        try:
            for key in jsondata[i].keys():

                try:
                    key = key.encode('UTF-8')
                except Exception,e:
                    key = key

                value =jsondata[i][key]

                try:
                    value = value.encode('UTF-8')
                except Exception,e:
                    value = value

                try:
                    value = value.replace('"','')
                except Exception,e:
                    value = value

                if 'Id' in key:
                    print('Record Added/Updated for '+tblName+' :'+str(value))

                if value is not None:
                    cols = cols + key + ','
                    vals = vals +'"'+ str(value)+ '",'
開發者ID:WinjitTech,項目名稱:moovah,代碼行數:45,代碼來源:Locations.py

示例6: insertOrUpdateRecord

                if 'SurveyMapping' in key:
                    insertOrUpdateRecord(value,'SurveyBoxMapping',Id)
                else:
                    if 'SurveyQuestions' in key and not 'SurveyQuestionsOptions' in key:
                        insertOrUpdateRecord(value,"SurveyQuestions",Id)
                    else:
                        if 'SurveyQuestionsOptions' in key:
                            insertOrUpdateRecord(value,"SurveyQuestionOptions",Id)
                        else:
                            if value is not None:
                                cols = cols + key + ','
                                vals = vals +'"'+ str(value)+ '",'

            query += cols[:-1] +') values('+vals[:-1]+');'
            c.execute(query)

        except Exception,e:
            print 'Insert Error for ['+ tblName +'] id=' + str(Id) +' details:'+ str(e)+'\nQuery:'+query
            continue

imgpath = GetCMSData.GetData('Surveys')

insertOrUpdateRecord(imgpath,"Survey",None)

con = sqlite3.connect(ConfReader.GetSyncDBPath())
con.isolation_level = None
c = con.cursor()
c.execute("update Survey set ProvinceId = -1 where ProvinceId is Null;")
con.close()
開發者ID:WinjitTech,項目名稱:moovah,代碼行數:29,代碼來源:Survey.py

示例7: print

                if 'Id' in key:
                    print('Record Added/Updated for '+tblName+' :'+str(value))

                if 'AlbumDetails' in key:
                    insertOrUpdateRecord(value,'AlbumDetails')
                else:
                    if 'BoxMappings' in key:
                        insertOrUpdateRecord(value,"ArticleBoxMapping")
                    else:
                        if value is not None:
                            cols = cols + key + ','
                            vals = vals +'"'+ str(value)+ '",'

            query += cols[:-1] +') values('+vals[:-1]+');'
            c.execute(query)
            #print(query)

        except Exception,e:
            print 'Insert Error for ['+ tblName +'] id=' + str(Id) +' details:'+ str(e)
            continue
    #db.commit()



#def LoadDB():

    #imgpath = GetCMSData.GetData('Adverts')

    #insertOrUpdateRecord(imgpath,"Language")
開發者ID:WinjitTech,項目名稱:moovah,代碼行數:29,代碼來源:Languages.py

示例8: insertOrUpdateRecord

def insertOrUpdateRecord(jsondata, tblName):

    for i in range(len(jsondata)):
        Id = jsondata[i]["Id"]

        query = "delete from " + tblName + " where Id='" + str(Id) + "'"

        c.execute(query)

        if "BoxID" in jsondata[i].keys() and "ReferenceID" in jsondata[i].keys():
            query = (
                "delete from "
                + tblName
                + " where BoxID='"
                + str(jsondata[i]["BoxID"])
                + "'"
                + " and ReferenceID='"
                + str(jsondata[i]["ReferenceID"])
                + "'"
            )
            print ("Record deleted for " + tblName + " :" + str(Id))
            c.execute(query)

        query = "insert into " + tblName + "("
        cols = ""
        vals = ""
        try:
            for key in jsondata[i].keys():

                try:
                    key = key.encode("UTF-8")
                except Exception, e:
                    key = key

                value = jsondata[i][key]

                try:
                    value = value.encode("UTF-8")
                except Exception, e:
                    value = value

                try:
                    value = value.replace('"', "")
                except Exception, e:
                    value = value

                # Check if it is a file to download and download it.
                if "IsActive" in jsondata[i].keys():
                    if jsondata[i]["IsActive"] == 1:
                        FileMgr.CheckAndDownloadFile(key, value, 0, Id)
                else:
                    FileMgr.CheckAndDownloadFile(key, value, 0, Id)

                if "Id" in key:
                    print ("Record Added/Updated for " + tblName + " :" + str(value))

                if "AlbumDetails" in key:
                    insertOrUpdateRecord(value, "AlbumDetails")
                else:
                    if "BoxMappings" in key:
                        insertOrUpdateRecord(value, "ArticleBoxMapping")
                    else:
                        if value is not None:
                            cols = cols + key + ","
                            vals = vals + '"' + str(value) + '",'
開發者ID:WinjitTech,項目名稱:moovah,代碼行數:65,代碼來源:TermsAndCondition.py

示例9: insertOrUpdateRecord

def insertOrUpdateRecord(jsondata,tblName,ParentID):

    if 'CompetitionBoxMapping' in tblName and ParentID is not None:
        query = "delete from " + tblName + " where CompetitionID='" + str(ParentID) + "'"
        print('Records deleted for ' + tblName + ' for CompetitionID :' + str(ParentID))
        c.execute(query)

    for i in range(len(jsondata)):
        Id = jsondata[i]['Id']

        query ="delete from "+tblName+" where Id='"+str(Id)+"'"

        c.execute(query)

        if "BoxID" in jsondata[i].keys() and "CompetitionID" in jsondata[i].keys():
            query ="delete from "+tblName+" where BoxID='"+str(jsondata[i]['BoxID'])+"'" + " and CompetitionID='"+str(jsondata[i]['CompetitionID'])+"'"
            print('Record deleted for '+tblName+' :'+str(Id))
            c.execute(query)


        query ='insert into '+tblName+'('
        cols = ''
        vals = ''
        try:
            for key in jsondata[i].keys():

                try:
                    key = key.encode('UTF-8')
                except Exception,e:
                    key = key

                value =jsondata[i][key]

                try:
                    value = value.encode('UTF-8')
                except Exception,e:
                    value = value

                try:
                    value = value.replace('"','')
                except Exception,e:
                    value = value


                #Check if it is a file to download and download it.
                if "IsActive" in jsondata[i].keys():
                    if jsondata[i]["IsActive"]==1:
                        FileMgr.CheckAndDownloadFile(key,value,4,Id)
                else:
                    FileMgr.CheckAndDownloadFile(key,value,4,Id)


                if 'Id' in key:
                    print('Record Added/Updated for '+tblName+' :'+str(value))

                if 'CompetitionMapping' in key:
                    insertOrUpdateRecord(value,'CompetitionBoxMapping',Id)
                else:
                    if 'CompetitionQuestions' in key and not 'CompetitionQuestionsOptions' in key:
                        insertOrUpdateRecord(value,'CompetitionQuestions',Id)
                    else:
                        if 'CompetitionQuestionsOptions' in key:
                            insertOrUpdateRecord(value,"CompetitionQuestionOptions",Id)
                        else:
                            if 'CompetitionWinners' in key:
                                insertOrUpdateRecord(value,"CompetitionWinner",Id)
                            else:
                                if value is not None:
                                    cols = cols + key + ','
                                    vals = vals +'"'+ str(value)+ '",'
開發者ID:WinjitTech,項目名稱:moovah,代碼行數:70,代碼來源:Competition.py


注:本文中的SyncDBMgr類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。