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


Python PySQLPool.getNewQuery方法代码示例

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


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

示例1: get_uuid

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
    def get_uuid(self):
        """Create the Database Querys"""
        query = PySQLPool.getNewQuery(self._db)
        query.execute("SELECT * FROM `mc_caching` WHERE `id`=%s and `flag_delete`='0' and `aktiv`='1'", (self._entry))

        for row in query.record:
            return row["mc_uuid"]
开发者ID:eieste,项目名称:mccaching,代码行数:9,代码来源:update_worker.py

示例2: insert_new_important_service

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
def insert_new_important_service(request_data):
    service_name = request_data['Services_name']
    instance = request_data['oop_name']
    business_name = request_data['business_name']
    ip = request_data['ip_address']
    editor = request_data['editor'] if request_data['editor'] else ''
    description = request_data['description'] if request_data['description'] else ''
    import datetime

    date_time = datetime.datetime.strptime(request_data['input_date'], '%Y%m%d')
    sql = config_mysql.ADD_NEW_IMPORTANT_SERVICE.format(service_name, ip, description, editor,
                                                        date_time, business_name, instance)
    print sql
    try:
        query = PySQLPool.getNewQuery(connection)
        query.Query(sql)
        query.Query("commit;")
        row_id = query.lastInsertID
        if query.affectedRows == 1:
            return True
        else:
            return False
    except:
        traceback.print_exc()
        return False
开发者ID:zhthb2087,项目名称:BusiRelation,代码行数:27,代码来源:model_mysql.py

示例3: _loadsql

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
	def _loadsql(self, users):
		try:
			sql_1 = "SELECT `user_id`, `token`, `action` FROM `white_list_users`"
			sql_2 = "DELETE FROM `white_list_users` WHERE `user_id` = '{0}'"

			res={}
			rules={}
			clean_rules=list()

			for uid in users:
				if users[uid] in self._exclude_mails:
					continue
				res[users[uid]] = {}

			query = PySQLPool.getNewQuery(self._sql_pool, True)

			query.Query(sql_1)
			for row in query.record:
				tmp = {}
				tmp[row["token"].lower()] = row["action"]
				if users.has_key(str(int(row["user_id"]))):
					res[users[str(int(row["user_id"]))]].update(tmp)
				else:
					if not self._keep_rules:
						clean_rules.append(row["user_id"])
						
			if not self._keep_rules:
				clean_rules = list(set(clean_rulse))
				for id in clean_rulse:
					query.Query(sql_2.format(id))
			return res
		except:
			if self._debug:
				logging.debug("Error in getting SQL data for UserLdap policy. Traceback: \n{0}\n".format(traceback.format_exc()))
			return None
开发者ID:flant,项目名称:LMPD,代码行数:37,代码来源:UserPolicyLDAP.py

示例4: get_history_volumn_detail_accord_property

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
def get_history_volumn_detail_accord_property(ip_address, property_name, start_time, end_time):
    '''

    '''
    property_name = string.lower(property_name)
    table_name = ''
    sql = ''
    result = []
    if property_name.find('service') != -1:
        table_name = model_redis.get_service_table_accord_ip(ip_address)
        sql = config_mysql.GET_HIS_VOLUMN_ACCORD_SERVICE.format(table_name, ip_address, start_time, end_time)
    else:
        property_type = get_property_type(property_name)
        if property_type != '':
            table_name = config_mysql.PRO_TO_TABLE[property_type]
            sql = config_mysql.HIS_SQL_TEMPLATE.format(property_name, table_name,
                                                       ip_address, start_time, end_time)
        else:
            table_name = model_redis.get_service_table_accord_ip(ip_address)
            sql = config_mysql.GET_HIS_VOLUMN_ACCORD_THE_SERVICE.format(table_name, ip_address, property_name,
                                                                        start_time, end_time)
    if sql != '':
        print sql
        query = PySQLPool.getNewQuery(his_conn)
        query.Query(sql)
        for item in query.record:
            item['time'] = utils.date_to_timestamp_general(item['time'], '%Y%m%d-%H')
            result.append(item)
        print result
        return {
            'ip_address': ip_address,
            'property_name': property_name,
            'property_value': result
        }
开发者ID:zhthb2087,项目名称:BusiRelation,代码行数:36,代码来源:model_mysql.py

示例5: regionID

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
def regionID(id):
    query = PySQLPool.getNewQuery(db)
    query.Query("""SELECT regionID from eve.mapRegions where regionName = %s""", (id,))
    if len(query.record) != 1:
        return None
    for row in query.record:
        return row['regionID']
开发者ID:Snipa22,项目名称:eveapps,代码行数:9,代码来源:webapp.py

示例6: repoThread

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
def repoThread():
    global repoList
    global repoVal
    while len(repoList) > 0:
        row = repoList.pop()
        regions = regionList()
        prices = getMineralBasket()
        refValue = ((row['Tritanium'] * prices['Tritanium']['sellavg']) +
        (row['Pyerite'] * prices['Pyerite']['sellavg']) +
        (row['Mexallon'] * prices['Mexallon']['sellavg']) +
        (row['Isogen'] * prices['Isogen']['sellavg']) +
        (row['Nocxium'] * prices['Nocxium']['sellavg']) +
        (row['Zydrine'] * prices['Zydrine']['sellavg']) +
        (row['Megacyte'] * prices['Megacyte']['sellavg']) +
        (row['Morphite'] * prices['Morphite']['sellavg'])) / row['portion']
        queryValue = PySQLPool.getNewQuery(db)
        stuff = refValue * 1.02
        queryValue.Query("""SELECT region, sellavg, sell, buy, buyavg from prices where itemid = %s""" % (row['typeID'],))
        for rowValue in queryValue.record:
            if rowValue['sellavg'] > stuff:
                continue
            if rowValue['sellavg'] != 0 and refValue/rowValue['sellavg'] * 100 > 100:
                repoVal[regions[rowValue['region']]][itemName(row['typeID'])] = {'sellavg': rowValue['sellavg'], 'sell': rowValue['sell'], 'buy': rowValue['buy'], 'buyavg': rowValue['buyavg'], 'refprice': refValue, 'percentage': refValue/rowValue['sellavg']* 100}
            elif rowValue['sellavg'] == 0 and rowValue['sell'] != 0 and refValue/rowValue['sell'] * 100 > 100:
                repoVal[regions[rowValue['region']]][itemName(row['typeID'])] = {'sellavg': rowValue['sellavg'], 'sell': rowValue['sell'], 'buy': rowValue['buy'], 'buyavg': rowValue['buyavg'], 'refprice': refValue, 'percentage': refValue/rowValue['sell'] * 100}
            else:
                continue
开发者ID:Snipa22,项目名称:eveapps,代码行数:29,代码来源:webapp.py

示例7: _loadsql

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
    def _loadsql(self):
        try:
            sql_1 = "SELECT `white_list_users`.`id`, `users`.`username`, `white_list_users`.`token`, `white_list_users`.`action` FROM `users` RIGHT JOIN `white_list_users` ON `users`.`id` = `white_list_users`.`user_id`"
            sql_2 = "DELETE FROM `white_list_users` WHERE `id` = {0}"

            res = {}
            users = {}
            rules = {}
            clean_rulse = list()

            query = PySQLPool.getNewQuery(self._sql_pool, True)

            query.Query(sql_1)
            for row in query.record:
                if not self._keep_rules and row["username"] == None:
                    clean_rulse.append(int(row["id"]))
                if row["username"] == None:
                    continue
                if row["username"].lower() in self._exclude_mails:
                    continue
                if not res.has_key(row["username"].lower()):
                    res[row["username"].lower()] = dict()
                res[row["username"].lower()][row["token"].lower()] = row["action"]

            for iter in clean_rulse:
                query.Query(sql_2.format(iter))

            return res
        except:
            if self._debug:
                logging.debug(
                    "Error in getting SQL data for User policy. Traceback: \n{0}\n".format(traceback.format_exc())
                )

            return None
开发者ID:flant,项目名称:LMPD,代码行数:37,代码来源:UserPolicy.py

示例8: fillQueue

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
 def fillQueue(self):
     query = PySQLPool.getNewQuery(self._db)
     query.execute("SELECT id FROM `mc_caching` WHERE last_crawl <= DATE_SUB(NOW(),INTERVAL 1 MINUTE) and `aktiv`='1' and `flag_delete`='0' ORDER BY `last_crawl` ASC")
     for row in query.record:
         if not row['id'] in self._queue.queue:
             self._queue.put(row["id"])
     return
开发者ID:eieste,项目名称:mccaching,代码行数:9,代码来源:filler.py

示例9: load_database_entry

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
 def load_database_entry(self):
     """Create the Database Querys"""
     query = PySQLPool.getNewQuery(self._db)
     query.execute("SELECT * FROM `mc_versioning` WHERE `mc_caching_id`=%s and `flag_delete`='0' and `aktiv`='1'", (self._entry))
     #data = query.record
     for data in query.record:
         return data
开发者ID:eieste,项目名称:mccaching,代码行数:9,代码来源:update_worker.py

示例10: save_data

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
def save_data (table, url, node, dns, https, http, http_code, download_size, fst_byte, ping):
    global conn, db, hostname, username, password, database

    tmp="insert into " + table + " (host, node, dns_time, https_time, http_time, code, size, 1st_byte, ping) values ('%s', '%s', %.3f, %.3f, %.3f, %d, %d, %.3f, %.3f)" %(url[1], node, dns, https, http, http_code, download_size, fst_byte, ping)
    print tmp

    conn = PySQLPool.getNewQuery(db,commitOnEnd=True)
    conn.Query(tmp)
开发者ID:silasistefan,项目名称:mo.nitor.me,代码行数:10,代码来源:monitor.py

示例11: get_important_service_accord_ip

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
def get_important_service_accord_ip(ip_address):
    result = []
    sql = config_mysql.GET_IMPORTANT_SERVICE_ACCORD_IP.format(ip_address)
    query = PySQLPool.getNewQuery(connection)
    try:
        query.Query(sql)
        result = list(set([item['service_name'] for item in list(query.record)]))
    except Exception, e:
        print e.message
开发者ID:zhthb2087,项目名称:BusiRelation,代码行数:11,代码来源:model_mysql.py

示例12: get_id

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
def get_id(conn, api_key):
  res = None

  query = PySQLPool.getNewQuery(connection=conn)
  r = query.Query("SELECT MEM_SQ FROM TBMB_ISSVC WHERE  SVC_APIKEY = %s", (api_key))
  if r == 1:
    res = query.record[0]['MEM_SQ']

  return res
开发者ID:carriercomm,项目名称:Generic-RESTful-API-Server,代码行数:11,代码来源:dbquery.py

示例13: get_secret

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
def get_secret(conn, api_key):
  res = None

  query = PySQLPool.getNewQuery(connection=conn)
  r = query.Query("SELECT SVC_SECRETKEY FROM TBMB_ISSVC WHERE SVC_APIKEY = %s", (api_key))
  if r == 1:
    res = query.record[0]['SVC_SECRETKEY']

  return res
开发者ID:carriercomm,项目名称:Generic-RESTful-API-Server,代码行数:11,代码来源:dbquery.py

示例14: testQuickQueryCreation

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
 def testQuickQueryCreation(self):
     """
     Quick Query Creation
     """
     try:
         query = PySQLPool.getNewQuery(self.connection)
         self.assertTrue(isinstance(query, PySQLPool.query.PySQLQuery))
     except Exception, e:
         self.fail('Failed to create PySQLQuery Object with error: '+str(e))
开发者ID:Kuv,项目名称:PySQLPool,代码行数:11,代码来源:testQuery.py

示例15: getResult

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewQuery [as 别名]
 def getResult(self,sql_query):
     """
     Get result form database when SQL query statement
     :param sql_query: SQL Query
     :return data: Object Array of the results
     """
     query = PySQLPool.getNewQuery(connection)
     query.Query(sql_query)
     data = query.record
     return data
开发者ID:robrotheram,项目名称:wePredictAPI,代码行数:12,代码来源:db.py


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