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


Python DataStore.executeSQL方法代码示例

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


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

示例1: recordServerInfo

# 需要导入模块: import DataStore [as 别名]
# 或者: from DataStore import executeSQL [as 别名]
def recordServerInfo(serverURL):
    sic = ServerInfoChecker.ServerInfoChecker(serverURL)
    commitID = sic.getCommitID()
    buildID = sic.getBuildID()
    serverName = re.findall('https://([^.]+).int.', serverURL)[0]
    executeTime = 'DATETIME(\'NOW\')'
    
    # Create table if the table for storing the server info is not exist.
    tableCreateString = ''' CREATE TABLE IF NOT EXISTS SERVER_INFO ( ID INTEGER PRIMARY KEY,
                                                                SERVER_NAME VARCHAR(50),
                                                                SERVER_URL VARCHAR(200),
                                                                BUILD_ID VARCHAR(100),
                                                                BUILD_ID_PUDATED INTEGER,
                                                                BUILD_ID_LAST_UPDATE_TIME DATETIME,
                                                                COMMIT_ID VARCHAR(200),
                                                                COMMIT_ID_UPDATED INTEGER,
                                                                COMMIT_ID_LAST_UPDATE_TIME DATETIME,
                                                                EXECUTE_TIME DATETIME
                                                                );'''
    DataStore.tableCreator(dbName, tableCreateString)
    
    sqlStringQueryLastCommitID = 'SELECT COMMIT_ID,COMMIT_ID_LAST_UPDATE_TIME,BUILD_ID,BUILD_ID_LAST_UPDATE_TIME FROM SERVER_INFO WHERE SERVER_URL = \'' + serverURL + '\' ORDER BY EXECUTE_TIME DESC LIMIT 1;'
    qResults = DataStore.executeSQL(dbName, sqlStringQueryLastCommitID)

    if len(qResults) > 0:
        queryResult = qResults[0]
        lastCommitID = str(queryResult[0])
        commitIDLastUpdateTime = str(queryResult[1])
        lastBuildID = str(queryResult[2])
        buildIDLastUpdateTime = str(queryResult[3])
        
        if commitID == lastCommitID:
            commitIDUpdated = 0
            #commitIDLastUpdateTime = 'DATATIME(' + commitIDLastUpdateTime + ')'
            commitIDLastUpdateTime = '\'' + commitIDLastUpdateTime + '\''
        else:
            commitIDUpdated = 1
            #commitIDLastUpdateTime = 'DATETIME(\'NOW\')'        
            commitIDLastUpdateTime = executeTime
                    
        if buildID == lastBuildID:
            buildIDUpdated = 0
            buildIDLastUpdateTime = '\'' + buildIDLastUpdateTime + '\''
        else:
            buildIDUpdated = 1
            #buildIDLastUpdateTime = 'DATETIME(\'NOW\')' 
            buildIDLastUpdateTime = executeTime
    else:
        commitIDUpdated = 1
        #commitIDLastUpdateTime = 'DATETIME(\'NOW\')'
        commitIDLastUpdateTime = executeTime
        buildIDUpdated = 1
        #buildIDLastUpdateTime = 'DATETIME(\'NOW\')'
        buildIDLastUpdateTime = executeTime
        
    #print(lastCommitID)
    
    #sqlStringQueryLastBuildID = 
    
    sqlStringInsertServerInfo = 'INSERT INTO SERVER_INFO VALUES(null, \'' + serverName + '\', \'' + serverURL + '\', \'' + buildID + '\','  + str(buildIDUpdated) + ', ' + buildIDLastUpdateTime + ', \'' + commitID + '\',' + str(commitIDUpdated) +', ' + commitIDLastUpdateTime + ', ' + executeTime + ');'

    DataStore.executeSQL(dbName, sqlStringInsertServerInfo)
开发者ID:Tony-WeiFeng,项目名称:Ultra-Server-Info-Checker,代码行数:64,代码来源:ServerInfoRecorder.py


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