Python twisted.enterprise.adbapi 模块,ConnectionPool() 实例源码

我们从Python开源项目中,提取了以下43个代码示例,用于说明如何使用twisted.enterprise.adbapi.ConnectionPool()

项目:Tieba_Spider    作者:Aqua-Dream    | 项目源码 | 文件源码
def __init__(self, settings):
        dbname = settings['MYSQL_DBNAME']
        tbname = settings['TIEBA_NAME']
        if not dbname.strip():
            raise ValueError("No database name!")
        if not tbname.strip():
            raise ValueError("No tieba name!")          
        if isinstance(tbname, unicode):
            settings['TIEBA_NAME'] = tbname.encode('utf8')

        self.settings = settings

        self.dbpool = adbapi.ConnectionPool('MySQLdb',
            host=settings['MYSQL_HOST'],
            db=settings['MYSQL_DBNAME'],
            user=settings['MYSQL_USER'],
            passwd=settings['MYSQL_PASSWD'],
            charset='utf8mb4',
            cursorclass = MySQLdb.cursors.DictCursor,
            init_command = 'set foreign_key_checks=0' #??????
        )
项目:ArticleSpider    作者:mtianyan    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbparms = dict(
            host = settings["MYSQL_HOST"],
            db = settings["MYSQL_DBNAME"],
            user = settings["MYSQL_USER"],
            passwd = settings["MYSQL_PASSWORD"],
            charset='utf8',
            cursorclass=MySQLdb.cursors.DictCursor,
            use_unicode=True,
        )
        dbpool = adbapi.ConnectionPool("MySQLdb", **dbparms)

        return cls(dbpool)
项目:ArticleSpider    作者:mtianyan    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbparms = dict(
            host=settings["MYSQL_HOST"],
            db=settings["MYSQL_DBNAME"],
            user=settings["MYSQL_USER"],
            passwd=settings["MYSQL_PASSWORD"],
            charset='utf8',
            cursorclass=MySQLdb.cursors.DictCursor,
            use_unicode=True,
        )
        dbpool = adbapi.ConnectionPool("MySQLdb", **dbparms)

        return cls(dbpool)
项目:ArticleSpider    作者:mtianyan    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbparms = dict(
            host=settings["MYSQL_HOST"],
            db=settings["MYSQL_DBNAME"],
            user=settings["MYSQL_USER"],
            passwd=settings["MYSQL_PASSWORD"],
            charset='utf8',
            cursorclass=MySQLdb.cursors.DictCursor,
            use_unicode=True,
        )
        dbpool = adbapi.ConnectionPool("MySQLdb", **dbparms)

        return cls(dbpool)
项目:ArticleSpider    作者:mtianyan    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbparms = dict(
            host=settings["MYSQL_HOST"],
            db=settings["MYSQL_DBNAME"],
            user=settings["MYSQL_USER"],
            passwd=settings["MYSQL_PASSWORD"],
            charset='utf8',
            cursorclass=MySQLdb.cursors.DictCursor,
            use_unicode=True,
        )
        dbpool = adbapi.ConnectionPool("MySQLdb", **dbparms)

        return cls(dbpool)
项目:Acfun_article_spider    作者:bbbbx    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbparms = dict(
            host = settings["MYSQL_HOST"],
            db = settings["MYSQL_DBNAME"],
            user = settings["MYSQL_USER"],
            password = settings["MYSQL_PASSWORD"],
            charset = "utf8",
            cursorclass = MySQLdb.cursors.DictCursor,
            use_unicode = True,
        )
        dbpool = adbapi.ConnectionPool("MySQLdb", **dbparms)
        return cls(dbpool)
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def __init__(self, info):
        self.info = info
        self.dbpool = adbapi.ConnectionPool(**self.info)
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def __setstate__(self, state):
        self.__dict__ = state
        self.info['password'] = getpass.getpass('Database password for %s: ' % (self.info['user'],))
        self.dbpool = adbapi.ConnectionPool(**self.info)
        del self.info['password']
项目:spider    作者:pythonsite    | 项目源码 | 文件源码
def from_settings(cls,settings):
        dbparms = dict(
            host = settings["MYSQL_HOST"],
            port = settings["MYSQL_PORT"],
            user = settings["MYSQL_USER"],
            passwd = settings["MYSQL_PASSWD"],
            db = settings["MYSQL_DB"],
            use_unicode = True,
            charset="utf8",
        )
        dbpool = adbapi.ConnectionPool("pymysql",**dbparms)
        return cls(dbpool)
项目:news    作者:wsdookadr    | 项目源码 | 文件源码
def set_up_client():
    # set up client with:
    #
    # set Twisted debug level
    # connect to the db
    global dbconn, dbd, dbpool
    DEBUG_MODE = True
    setDebugging(DEBUG_MODE)
    log.startLogging(sys.stdout)
    # db connection and deferred
    dbconn = txpostgres.Connection()
    dbd = dbconn.connect("dbname=news user=user password=test1 host=127.0.0.1 application_name='news-collect'")
    dbpool = adbapi.ConnectionPool('psycopg2', dbname='news', user='user', password='test1')
项目:web_crawler    作者:NearXdu    | 项目源码 | 文件源码
def __init__(self):
        dbargs = dict(
             host = '127.0.0.1',
             db = 'test',
             user = 'root',
             passwd = '123456',
             cursorclass = MySQLdb.cursors.DictCursor,
             charset = 'utf8',
             use_unicode = True
            )
        self.dbpool = adbapi.ConnectionPool('MySQLdb',**dbargs)
项目:NCspider    作者:build2last    | 项目源码 | 文件源码
def from_crawler(cls, crawler):
        settings = crawler.settings
        kw = dict(
            host=settings.get('MYSQL_HOST',' localhost'),
            port=settings.get('MYSQL_PORT', 3306),
            user=settings.get('MYSQL_USER', 'root'),
            db=settings.get('MYSQL_DB', 'test'),
            passwd=settings.get('MYSQL_PASSWD'),
            charset='utf8',
            use_unicode=True,
        )
        dbpool = adbapi.ConnectionPool ('MySQLdb', **kw)
        return cls (dbpool)
项目:scrapy_zhihu    作者:mockingbirds    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbparams = dict(
            host=settings["MYSQL_HOST"],
            port=settings["MYSQL_PORT"],
            user=settings["MYSQL_USER"],
            passwd=settings["MYSQL_PWD"],
            db=settings["MYSQL_DB"],
            charset=settings["MYSQL_CHARSET"],
            use_unicode=settings["MYSQL_USER_UNICODE"],
            cursorclass=MySQLdb.cursors.DictCursor,
        )
        # ????adbapi????dbpool????MyTwistedPipeline?????
        dbpool = adbapi.ConnectionPool("MySQLdb", **dbparams)
        return cls(dbpool)
项目:Daily-code    作者:rui7157    | 项目源码 | 文件源码
def __init__(self):
        self.dbpool = adbapi.ConnectionPool('pymysql',host='127.0.0.1', db='hospitalinfo',
                user='root', passwd='', cursorclass=pymysql.cursors.DictCursor,
                charset='utf8', use_unicode=True)
项目:PythonCrawler-Scrapy-Mysql-File-Template    作者:lawlite19    | 项目源码 | 文件源码
def __init__(self,dbpool):
        self.dbpool=dbpool
        ''' ?????????????????????????settings????????????
            self.dbpool=adbapi.ConnectionPool('MySQLdb',
                                          host='127.0.0.1',
                                          db='crawlpicturesdb',
                                          user='root',
                                          passwd='123456',
                                          cursorclass=MySQLdb.cursors.DictCursor,
                                          charset='utf8',
                                          use_unicode=False)'''
项目:Guazi    作者:xgkmxxx    | 项目源码 | 文件源码
def __init__(self):
        self.dbpool = adbapi.ConnectionPool('MySQLdb',
            db = 'guazi',
            user = 'root',
            passwd = '',
            cursorclass = MySQLdb.cursors.DictCursor,
            charset = 'utf8',
            use_unicode = True
            )
项目:tv_Spider    作者:tingyunsay    | 项目源码 | 文件源码
def __init__(self):
        self.dbpool=adbapi.ConnectionPool('MySQLdb',
                host='127.0.0.1',
                db='liaohong_test',
                user='root',
                passwd='liaohong',
                cursorclass=MySQLdb.cursors.DictCursor,
                charset='utf8',
                use_unicode=True)
项目:TvLive    作者:Rano1    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbparms = config.DB_config.get("mysql")
        dbparms['db'] = config.database
        dbparms['cursorclass'] = MySQLdb.cursors.DictCursor
        dbparms['use_unicode'] = True

        dbpool = adbapi.ConnectionPool("MySQLdb", **dbparms)

        return cls(dbpool)
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def __init__(self, info):
        self.info = info
        self.dbpool = adbapi.ConnectionPool(**self.info)
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def __setstate__(self, state):
        self.__dict__ = state
        self.info['password'] = getpass.getpass('Database password for %s: ' % (self.info['user'],))
        self.dbpool = adbapi.ConnectionPool(**self.info)
        del self.info['password']
项目:islam-buddy    作者:hamir    | 项目源码 | 文件源码
def __init__(self):    
        dbargs = settings.get('DB_CONNECT')    
        db_server = settings.get('DB_SERVER')    
        dbpool = adbapi.ConnectionPool(db_server, **dbargs)    
        self.dbpool = dbpool
项目:ScrapyProject    作者:chinesehuazhou    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbparams = dict(
            host=settings['MYSQL_HOST'],
            port=settings['MYSQL_PORT'],
            db=settings['MYSQL_DBNAME'],
            user=settings['MYSQL_USER'],
            passwd=settings['MYSQL_PASSWD'],
            charset=settings['MYSQL_CHARSET'],
            cursorclass=MySQLdb.cursors.DictCursor,
            use_unicode=False,
        )
        dbpool = adbapi.ConnectionPool('MySQLdb', **dbparams)  # **?????????????
        return cls(dbpool)

    # pipeline????
项目:floranet    作者:Fluent-networks    | 项目源码 | 文件源码
def start(self):
        """Create the ADBAPI connection pool.

        """
        Registry.DBPOOL = adbapi.ConnectionPool('psycopg2', host=self.host,
                  user=self.user, password=self.password,
                  database=self.database)
项目:dianping    作者:bsns    | 项目源码 | 文件源码
def from_settings(cls,settings):
        dbparams=dict(
            host=settings['MYSQL_HOST'],#??settings????
            db=settings['MYSQL_DBNAME'],
            user=settings['MYSQL_USER'],
            passwd=settings['MYSQL_PASSWD'],
            charset='utf8',#??????????????????
            cursorclass=MySQLdb.cursors.DictCursor,
            use_unicode=False,
        )
        dbpool=adbapi.ConnectionPool('MySQLdb',**dbparams)#**?????????????,???host=xxx,db=yyy....
        return cls(dbpool)#???dbpool???????self?????
项目:crondeamon    作者:zhoukunpeng504    | 项目源码 | 文件源码
def run_conn_fun(fun,*args):
    try:
        global conn
        result=yield  getattr(conn,fun)(*args)
    except (MySQLdb.OperationalError,adbapi.ConnectionLost):
        try:
            conn.close()
        except:
            pass
        conn=adbapi.ConnectionPool("MySQLdb",host=MYSQLCONFIG["host"],user=MYSQLCONFIG["user"],passwd=MYSQLCONFIG["passwd"],charset=MYSQLCONFIG["charset"],port=MYSQLCONFIG["port"],db=MYSQLCONFIG["db"],cp_reconnect=True)
        result=yield  getattr(conn,fun)(*args)
    defer.returnValue(result)
项目:wallstreetcnScrapy    作者:jianzhichun    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbargs = dict(
            host=settings['MYSQL_HOST'],
            db=settings['MYSQL_DBNAME'],
            user=settings['MYSQL_USER'],
            passwd=settings['MYSQL_PASSWD'],
            port=settings['MYSQL_PORT'],
            charset='utf8',
            use_unicode=True,
        )
        dbpool = adbapi.ConnectionPool('MySQLdb', **dbargs)
        return cls(dbpool)
项目:django-scrapy-lcv_search    作者:Albino1995    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbparms = dict(
            host = settings["MYSQL_HOST"],
            db = settings["MYSQL_DBNAME"],
            user = settings["MYSQL_USER"],
            password = settings["MYSQL_PASSWORD"],
            charset = 'utf8',
            cursorclass = MySQLdb.cursors.DictCursor,
            use_unicode = True,
        )
        dbpool = adbapi.ConnectionPool("MySQLdb",**dbparms)
        return cls(dbpool)
项目:scrapy_redis_spider    作者:lymlhhj123    | 项目源码 | 文件源码
def opened_spider(self, spider):
        self.db = adbapi.ConnectionPool(**self.config)
项目:fintech_spider    作者:hee0624    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbparms = dict(
            host = settings["MYSQL_HOST"],
            db = settings["MYSQL_DBNAME"],
            user = settings["MYSQL_USER"],
            passwd = settings["MYSQL_PASSWORD"],
            charset='utf8',
            cursorclass=MySQLdb.cursors.DictCursor,
            use_unicode=True,
        )
        dbpool = adbapi.ConnectionPool("MySQLdb", **dbparms)

        return cls(dbpool)
项目:fintech_spider    作者:hee0624    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbparms = dict(
            host=settings["MYSQL_HOST"],
            db=settings["MYSQL_DBNAME"],
            user=settings["MYSQL_USER"],
            passwd=settings["MYSQL_PASSWORD"],
            charset='utf8',
            cursorclass=MySQLdb.cursors.DictCursor,
            use_unicode=True,
        )
        dbpool = adbapi.ConnectionPool("MySQLdb", **dbparms)

        return cls(dbpool)
项目:jobbole_spider    作者:pujinxiao    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbparms = dict(
            host = settings["MYSQL_HOST"],
            db = settings["MYSQL_DBNAME"],
            user = settings["MYSQL_USER"],
            passwd = settings["MYSQL_PASSWORD"],
            charset='utf8',
            cursorclass=pymysql.cursors.DictCursor,
            use_unicode=True,
        )
        dbpool = adbapi.ConnectionPool("pymysql", **dbparms)
        return cls(dbpool)
项目:Crawlers    作者:mi-minus    | 项目源码 | 文件源码
def __init__(self):
        self.dbpool = adbapi.ConnectionPool(
                                    dbapiName = 'MySQLdb',
                                    host = 'localhost',
                                    db = 'sina_spider_db',
                                    user = 'root',
                                    passwd = 'gongli',
                                    cursorclass = MySQLdb.cursors.DictCursor,
                                    charset = 'utf8mb4',
                                    )
项目:Crawlers    作者:mi-minus    | 项目源码 | 文件源码
def __init__(self):
        self.dbpool = adbapi.ConnectionPool(
                                    dbapiName='MySQLdb',
                                    host=settings.DB_HOST,
                                    db=settings.DB,
                                    user=settings.DB_NAME,
                                    passwd=settings.DB_PASSWD,
                                    cursorclass= MySQLdb.cursors.DictCursor,
                                    charset = 'utf8',
                                    use_unicode = False
                                    )
项目:Crawlers    作者:mi-minus    | 项目源码 | 文件源码
def __init__(self):
        self.dbpool = adbapi.ConnectionPool(
                                    dbapiName='MySQLdb',
                                    host=settings.DB_HOST,
                                    db=settings.DB,
                                    user=settings.DB_NAME,
                                    passwd=settings.DB_PASSWD,
                                    cursorclass= MySQLdb.cursors.DictCursor,
                                    charset = 'utf8',
                                    use_unicode = False
                                    )
项目:FirstSpider    作者:yipwinghong    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbparms = dict(
            host=settings["MYSQL_HOST"],
            db=settings["MYSQL_DBNAME"],
            user=settings["MYSQL_USER"],
            passwd=settings["MYSQL_PASSWORD"],
            charset='utf8',
            cursorclass=MySQLdb.cursors.DictCursor,
            use_unicode=True,
        )
        dbpool = adbapi.ConnectionPool("MySQLdb", **dbparms)
        return cls(dbpool)      # dbpool???__init__

    # ??twisted?mysql????????
项目:music_Spider    作者:tingyunsay    | 项目源码 | 文件源码
def __init__(self):
        self.dbpool=adbapi.ConnectionPool('MySQLdb',
                host='127.0.0.1',
                db='liaohong_test',
                user='root',
                passwd='liaohong',
                cursorclass=MySQLdb.cursors.DictCursor,
                charset='utf8',
                use_unicode=True)
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
def __init__(self, info):
        self.info = info
        self.dbpool = adbapi.ConnectionPool(**self.info)
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
def __setstate__(self, state):
        self.__dict__ = state
        self.info['password'] = getpass.getpass('Database password for %s: ' % (self.info['user'],))
        self.dbpool = adbapi.ConnectionPool(**self.info)
        del self.info['password']
项目:spider    作者:qcl643062    | 项目源码 | 文件源码
def from_settings(cls, settings):
        dbargs = dict(
            host=settings['MYSQL_HOST'],
            db=settings['MYSQL_DBNAME'],
            user=settings['MYSQL_USER'],
            passwd=settings['MYSQL_PASSWD'],
            charset='utf8',
            cursorclass = MySQLdb.cursors.DictCursor,
            use_unicode= True,
        )
        dbpool = adbapi.ConnectionPool('MySQLdb', **dbargs)
        return cls(dbpool)
项目:tutorial    作者:zhaobin022    | 项目源码 | 文件源码
def __init__(self):
        self.dbpool = adbapi.ConnectionPool('MySQLdb', db='spiders',
                user='root', passwd='build.ns', cursorclass=MySQLdb.cursors.DictCursor,
                charset='utf8', use_unicode=True)
项目:python    作者:panxus    | 项目源码 | 文件源码
def adb_connect_db(db_type,**kwargs):
    '''
    db_type-->"MySQLdb"
    '''
    dbpool = adbapi.ConnectionPool(db_type, **kwargs)
    return dbpool
项目:python    作者:panxus    | 项目源码 | 文件源码
def adb_connect_db(db_type,**kwargs):
    '''
    db_type-->"MySQLdb"
    '''
    dbpool = adbapi.ConnectionPool(db_type, **kwargs)
    return dbpool
项目:python    作者:panxus    | 项目源码 | 文件源码
def adb_connect_db(db_type,**kwargs):
    '''
    db_type-->"MySQLdb"
    '''
    dbpool = adbapi.ConnectionPool(db_type, **kwargs)
    return dbpool