Python-mysql-pool(PyMysqlPool)
You can use the <i></i>python-mysql-pool<i></i>
[<a href="https:&#x2F;&#x2F;github.com&#x2F;LuciferJack&#x2F;python-mysql-pool][1]" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;LuciferJack&#x2F;python-mysql-pool][1]</a><p>so easy config and use support multi database and support dynamic pool and fixed pool.<p><pre><code>    step:1
    
    &quot;&quot;&quot;
    file:mysql_config.py change to your db config
    &quot;&quot;&quot;
    db_config = {
        &#x27;local&#x27;: {
            &#x27;host&#x27;: &quot;10.95.130.118&quot;, &#x27;port&#x27;: 8899,
            &#x27;user&#x27;: &quot;root&quot;, &#x27;passwd&#x27;: &quot;123456&quot;,
            &#x27;db&#x27;: &quot;marry&quot;, &#x27;charset&#x27;: &quot;utf8&quot;,
            &#x27;pool&#x27;: {
                #use = 0 no pool else use pool
                &quot;use&quot;:1,
                # size is &gt;=0,  0 is dynamic pool
                &quot;size&quot;:0,
                #pool name
                &quot;name&quot;:&quot;local&quot;,
            }
        },
        &#x27;poi&#x27;: {
            &#x27;host&#x27;: &quot;10.95.130.***&quot;, &#x27;port&#x27;: 8787,
            &#x27;user&#x27;: &quot;lujunxu&quot;, &#x27;passwd&#x27;: &quot;****&quot;,
            &#x27;db&#x27;: &quot;poi_relation&quot;, &#x27;charset&#x27;: &quot;utf8&quot;,
            &#x27;pool&#x27;: {
                #use = 0 no pool else use pool
                &quot;use&quot;:0,
                # size is &gt;=0,  0 is dynamic pool
                &quot;size&quot;:0,
                #pool name
                &quot;name&quot;:&quot;poi&quot;,
            }
        },
    }
    
    step:2
    
    &quot;&quot;&quot;
    Note:create your own table
    &quot;&quot;&quot;
    
    step:3 (example show below)
    
    &quot;&quot;&quot;
    pool size special operation
    &quot;&quot;&quot;
    def query_pool_size():
        job_status = 2
        _sql = &quot;select *  from master_job_list j  where j.job_status  in (%s) &quot;
        _args = (job_status,)
        task = query(db_config[&#x27;local&#x27;], _sql,_args)
        logging.info(&quot;query_npool method query_npool result is %s ,input _data is %s &quot;, task , _args)
        return
    
    &quot;&quot;&quot;
    single query
    &quot;&quot;&quot;
    def query_npool():
        job_status = 2
        _sql = &quot;select *  from master_job_list j  where j.job_status  !=%s &quot;
        _args = (job_status,)
        task = query_single(db_config[&#x27;local&#x27;], _sql,_args)
        logging.info(&quot;query_npool method query_npool result is %s ,input _data is %s &quot;, task , _args)
        return
    
    &quot;&quot;&quot;
    insert
    &quot;&quot;&quot;
    def insert(nlp_rank_id,hit_query_word):
        #add more args
        _args = (nlp_rank_id,hit_query_word)
        _sql = &quot;&quot;&quot;INSERT INTO nlp_rank_poi_online (nlp_rank_id,hit_query_word,rank_type,poi_list,poi_raw_list,article_id,city_id,status,create_time,version,source_from) VALUES (%s,%s,%s, %s, %s,%s, %s,%s, %s,%s,%s)&quot;&quot;&quot;
        affect = insertOrUpdate(db_config[&#x27;local&#x27;], _sql, _args)
        logging.info(&quot;insert method insert result is %s ,input _data is %s &quot;, affect , _args)
        return
    
    &quot;&quot;&quot;
    update
    &quot;&quot;&quot;
    def update(query_word,query_id):
        _args = (query_word,query_id)
        _sql = &quot;&quot;&quot;update nlp_rank  set query_word = %s  WHERE  id = %s&quot;&quot;&quot;
        affect = insertOrUpdate(db_config[&#x27;local&#x27;], _sql, _args)
        logging.info(&quot;update method update result is %s ,input _data is %s &quot;, affect , _args)
        return


  [1]: https:&#x2F;&#x2F;github.com&#x2F;LuciferJack&#x2F;python-mysql-pool</code></pre>