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


Python PySQLPool类代码示例

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


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

示例1: run

	def run(self):

		with Connection.Connection(self.socket, self.name, self.debug) as conn:
			while conn.get_message():

				answer = self.default_answer

				if conn["sender"] != "" and conn["recipient"] != "":
					if self.debug:
						logging.debug("Mail from {0} to {1} with SASL: {2}".format(conn["sender"], conn["recipient"], conn["sasl_username"]))
					for flt in self.flts:
						with self._mutex:
							try:
								flt_answer = flt.check(conn)
							except:
								logging.error("Error in checking policy {0}. Traceback: \n{1}\n".format(flt, traceback.format_exc()))
						if flt_answer:
							break

					if flt_answer:
						answer = flt_answer

					if self.debug:
						logging.debug("Answer for mail {0} to {1} was: {2}".format(conn["sender"], conn["recipient"], answer))

				if conn["request"] == "smtpd_access_policy":
					conn.answer(answer)
				try:
					PySQLPool.cleanupPool()
				except:
					logging.warn('Error in cleaning SQL pool. Traceback: \n{0}\n'.format(traceback.format_exc()))
		if self.debug:
			stop_time = time.time()
			logging.debug("Process named {0} started {1}, stopped {2}. Working {3} seconds.".format(self.name, time.strftime("%d.%m.%y - %H:%M:%S", time.localtime(self.start_time)), time.strftime("%d.%m.%y - %H:%M:%S", time.localtime(stop_time)), (stop_time - self.start_time)))
开发者ID:flant,项目名称:LMPD,代码行数:34,代码来源:Worker.py

示例2: set_conninfo

def set_conninfo(conn_info, max_pool_count = 3):
  conn = PySQLPool.getNewConnection(
           host     = conn_info["hostname"],
           username = conn_info["username"],
           password = conn_info["password"],
           schema   = conn_info["schema"]
         )
  PySQLPool.getNewPool().maxActiveConnections = max_pool_count

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

示例3: TestConnect

def TestConnect(sAddr, nPort, sUser, sPasswd):
    try:
        testConn = PySQLPool.getNewConnection(username=sUser, password=sPasswd, host=sAddr, port=nPort, db='mysql', charset='utf8')
        query = PySQLPool.getNewQuery(testConn)
        query.query(r'select * from user')

        return True, '成功'
    except Exception,e:
        print e
        return False,e
开发者ID:0xr0ot,项目名称:Sravana,代码行数:10,代码来源:database.py

示例4: testDBConnection

	def testDBConnection(self):
		"""
		Test actual connection to Database
		"""
		connDict = {
					"host":self.host,
					"user":self.username,
					"passwd":self.password,
					"db":self.db}
		connection = PySQLPool.getNewConnection(**connDict)
		query = PySQLPool.getNewQuery(connection)
		query.Query("select current_user")
		result = str(query.record[0]['current_user']).split('@')[0]
		self.assertEqual(result, 'unittest', "DB Connection Failed")
开发者ID:kaminey,项目名称:pysqlpool,代码行数:14,代码来源:connection.py

示例5: testQuickQueryCreation

	def testQuickQueryCreation(self):
		"""
		Quick Query Creation
		"""
		try:
			connDict = {
						"host":self.host,
						"user":self.username,
						"passwd":self.password,
						"db":self.db}
			connection = PySQLPool.getNewConnection(**connDict)
			query = PySQLPool.getNewQuery(connection)
		except Exception, e:
			self.fail('Failed to create PySQLQuery Object')
开发者ID:kaminey,项目名称:pysqlpool,代码行数:14,代码来源:connection.py

示例6: fillQueue

 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,代码行数:7,代码来源:filler.py

示例7: get_uuid

    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,代码行数:7,代码来源:update_worker.py

示例8: regionID

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,代码行数:7,代码来源:webapp.py

示例9: _loadsql

	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,代码行数:35,代码来源:UserPolicyLDAP.py

示例10: repoThread

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,代码行数:27,代码来源:webapp.py

示例11: _loadsql

    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,代码行数:35,代码来源:UserPolicy.py

示例12: load_database_entry

 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,代码行数:7,代码来源:update_worker.py

示例13: get_history_volumn_detail_accord_property

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,代码行数:34,代码来源:model_mysql.py

示例14: insert_new_important_service

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,代码行数:25,代码来源:model_mysql.py

示例15: manytasks

def manytasks(sas):
  connection = PySQLPool.getNewConnection(username='root', password='password', host='localhost', db='sandyfiles')
  

  for i in range(2):
    t = Thread(target=checksamples, args=(i,connection,))
    t.start() 
开发者ID:BwRy,项目名称:sandy,代码行数:7,代码来源:mthreadbk.py


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