当前位置: 首页>>代码示例>>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;未经允许,请勿转载。