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


Python MySQLWrapper.insert方法代碼示例

本文整理匯總了Python中DIRAC.ResourceStatusSystem.Utilities.MySQLWrapper.insert方法的典型用法代碼示例。如果您正苦於以下問題:Python MySQLWrapper.insert方法的具體用法?Python MySQLWrapper.insert怎麽用?Python MySQLWrapper.insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DIRAC.ResourceStatusSystem.Utilities.MySQLWrapper的用法示例。


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

示例1: insert

# 需要導入模塊: from DIRAC.ResourceStatusSystem.Utilities import MySQLWrapper [as 別名]
# 或者: from DIRAC.ResourceStatusSystem.Utilities.MySQLWrapper import insert [as 別名]
  def insert( self, params, meta ):
    '''
    Inserts args in the DB making use of kwargs where parameters such as
    the 'table' are specified ( filled automatically by the Client). Typically you 
    will not pass kwargs to this function, unless you know what are you doing 
    and you have a very special use case.

    :Parameters:
      **params** - `dict`
        arguments for the mysql query ( must match table columns ! ).

      **meta** - `dict`
        metadata for the mysql query. It must contain, at least, `table` key
        with the proper table name.

    :return: S_OK() || S_ERROR()
    '''

    utcnow = datetime.utcnow().replace( microsecond = 0 )

    # We force lastCheckTime to utcnow if it is not present on the params
    #if not( 'lastCheckTime' in params and not( params[ 'lastCheckTime' ] is None ) ):
    if 'lastCheckTime' in params and params[ 'lastCheckTime' ] is None:  
      params[ 'lastCheckTime' ] = utcnow  

    if 'dateEffective' in params and params[ 'dateEffective' ] is None:
      params[ 'dateEffective' ] = utcnow
    
    return MySQLWrapper.insert( self, params, meta )
開發者ID:cgrefe,項目名稱:DIRAC,代碼行數:31,代碼來源:ResourceManagementDB.py


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