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


Python PySQLPool.getNewConnection方法代码示例

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


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

示例1: manytasks

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
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,代码行数:9,代码来源:mthreadbk.py

示例2: testQuickConnectionCreation

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
	def testQuickConnectionCreation(self):
		"""
		Quick Connection Creation
		"""
		try:
			connection = PySQLPool.getNewConnection(host=self.host, user=self.username, passwd=self.password, db=self.db)
		except Exception, e:
			self.fail("Failed to create connection with error: "+str(e))
开发者ID:kaminey,项目名称:pysqlpool,代码行数:10,代码来源:connection.py

示例3: TestConnect

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
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,代码行数:12,代码来源:database.py

示例4: set_conninfo

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
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,代码行数:12,代码来源:dbquery.py

示例5: _connect_to_db

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
 def _connect_to_db(cls, db_name, db_user, db_passwd):
     try:
         connection = PySQLPool.getNewConnection(
                                                 host=cls.__config.db_host,
                                                 username=db_user,
                                                 password=cls.__aescoder.decrypt(db_passwd),
                                                 db=db_name,
                                                 commitOnEnd=True,
                                                 use_unicode=True,
                                                 charset = 'utf8')
     except MySQLdb.Error, e:
         raise Exception("connection %d: %s" % (e.args[0], e.args[1]))
开发者ID:Pthinker,项目名称:generator,代码行数:14,代码来源:db_conn.py

示例6: testQuickDictConnectionCreation

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
	def testQuickDictConnectionCreation(self):
		"""
		Quick Connection Creation using Kargs/Dict
		"""
		try:
			connDict = {
					"host":self.host,
					"user":self.username,
					"passwd":self.password,
					"db":self.db}
			connection = PySQLPool.getNewConnection(**connDict)
		except Exception, e:
			self.fail("Failed to create connection with error: "+str(e))
开发者ID:kaminey,项目名称:pysqlpool,代码行数:15,代码来源:connection.py

示例7: testDBConnection

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
	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,代码行数:16,代码来源:connection.py

示例8: testQuickQueryCreation

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
	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,代码行数:16,代码来源:connection.py

示例9: __init__

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
    def __init__(self, dbServerName):
        '''
        函数功能:
        参数:sDbServerName 选择操作数据库的放
        '''
        if config.g_databaseInfor[dbServerName]["watch_dog"]==False:
            #首次运行
            config.g_databaseInfor[dbServerName]["password"] = self.DecryptPassword(config.g_databaseInfor[dbServerName]["password"])
            config.g_databaseInfor[dbServerName]["watch_dog"] = True

        connection = PySQLPool.getNewConnection(username=config.g_databaseInfor[dbServerName]["user"], 
                                                password=config.g_databaseInfor[dbServerName]["password"], 
                                                host=config.g_databaseInfor[dbServerName]["addr"], 
                                                port =config.g_databaseInfor[dbServerName]["port"], 
                                                db = config.g_databaseInfor[dbServerName]["db_name"], 
                                                charset='utf8')
        self.pDBConn = connection
开发者ID:0xr0ot,项目名称:Sravana,代码行数:19,代码来源:database.py

示例10: getQueryObject

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
    def getQueryObject(**kwargs):
        """
        Get a new connection from the PySQLPool
        @return a new connection, of None if an error has occured
        """
        try:


            conn = PySQLPool.getNewConnection(host = 'localhost',
                username=  'root',
                password=  '',
                schema=  'test',
                port= 3306,
                commitOnEnd = True)
            query = PySQLPool.getNewQuery(connection = conn)

            return query
        #something went wrong
        except Exception, e:
            logging.error("Could not get query object: %s", e)
            return None
开发者ID:nivertech,项目名称:kickass-redis,代码行数:23,代码来源:users_example.py

示例11: main

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
from gevent import monkey; gevent.monkey.patch_all()
import zmq
import scipy.stats as stats
import numpy.ma as ma
import numpy as np
import PySQLPool
from config import config
from datetime import datetime
import time
import dateutil.parser

np.seterr(all='ignore')

PySQLPool.getNewPool().maxActiveConnections = 50

dbConn = PySQLPool.getNewConnection(user=config['username'],passwd=config['password'],db=config['db'], commitOnEnd=True)

# The maximum number of greenlet workers in the greenlet pool. This is not one
# per processor, a decent machine can support hundreds or thousands of greenlets.
# I recommend setting this to the maximum number of connections your database
# backend can accept, if you must open one connection per save op.
MAX_NUM_POOL_WORKERS = 300

def main():
    """
    The main flow of the application.
    """
    context = zmq.Context()
    subscriber = context.socket(zmq.SUB)

    # Connect to the first publicly available relay.
开发者ID:Snipa22,项目名称:eveapps,代码行数:33,代码来源:consumer.py

示例12: initMySQL

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
 def initMySQL(self):
     self.mainbus["functions"]["mysql_con"] = PySQLPool.getNewConnection(username=self.mainbus["runtimevar"]["config"]["mysql"]["username"], password=self.mainbus["runtimevar"]["config"]["mysql"]["password"], host=self.stripQuotes(self.mainbus["runtimevar"]["config"]["mysql"]["host"]), db=self.stripQuotes(self.mainbus["runtimevar"]["config"]["mysql"]["name"]))
开发者ID:eieste,项目名称:mccaching,代码行数:4,代码来源:__main__.py

示例13: getDB

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
def getDB():
    conn = PySQLPool.getNewConnection(**cherrypy.tree.apps[''].config["mysql"])
    return conn
开发者ID:nerdynick,项目名称:cherryslice,代码行数:5,代码来源:mysql.py

示例14: init

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
#!/usr/bin/env python
#coding=utf-8

import config
import cityhash
import PySQLPool
import tldextracter

connection = PySQLPool.getNewConnection(
    username=config.DB_USER,
    password=config.DB_PASSWORD,
    host=config.DB_HOST,
    db=config.DB_DB,
    charset=config.DB_CHARSET)


def init():
    '''
CREATE TABLE `news_sites` (
`id` INT UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
`domainhash` BIGINT UNSIGNED NOT NULL DEFAULT 0,
`language` TINYINT UNSIGNED DEFAULT 1 NOT NULL,
`name` VARCHAR(128) NOT NULL DEFAULT '',
`domain` VARCHAR(100) NOT NULL DEFAULT '',
`url` VARCHAR(512) NOT NULL DEFAULT ''
) Engine=INNoDB DEFAULT CHARSET=utf8;
    '''
    pass


def insert_site(name, language, url):
开发者ID:hackrole,项目名称:scrapy-utils,代码行数:33,代码来源:import_sites.py

示例15: Pool

# 需要导入模块: import PySQLPool [as 别名]
# 或者: from PySQLPool import getNewConnection [as 别名]
from hotqueue import HotQueue
import PySQLPool as pysqlpool
import gevent
from gevent.pool import Pool
from gevent import monkey; gevent.monkey.patch_all()
import emdr_config as config

# Max number of greenlet workers
MAX_NUM_POOL_WORKERS = 15

# use a greenlet pool to cap the number of workers at a reasonable level
gpool = Pool(size=MAX_NUM_POOL_WORKERS)

queue = HotQueue("emdr", unix_socket_path="/var/run/redis/redis.sock")
queue_history = HotQueue("emdr_history", unix_socket_path="/var/run/redis/redis.sock")
connection = pysqlpool.getNewConnection(username=config.dbuser, password=config.dbpass, unix_socket=config.dbsocket, db=config.dbname)
# connection = pysqlpool.getNewConnection(username=config.dbuser, password=config.dbpass, host=config.dbhost , db=config.dbname)

def main():
  for message in queue.consume():
    gpool.spawn(process, message)

def process(message):
  query = pysqlpool.getNewQuery(connection)
  
  market_json = zlib.decompress(message)
  market_data = unified.parse_from_json(market_json)
  insertData = []
  deleteData = []
  
  if market_data.list_type == 'orders':
开发者ID:jgkennedy,项目名称:emdr-process,代码行数:33,代码来源:emdr_process_orders.py


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