#/usr/bin/env python
#coding=utf-8

'''
Created on 2017-02-20

@author: chenjiahui
'''

import sys,os
from config import *
from tornado_mysql import pools

data_time=''

def create_pool():
    print DB_CONN.PORT,DB_CONN.BATCH_USER,DB_CONN.BATCH_PASSWORD,DB_CONN.DBNAME
    pool_db = pools.Pool(
        dict(host=DB_CONN.IP, port=int(DB_CONN.PORT), user=DB_CONN.BATCH_USER,
             passwd=DB_CONN.BATCH_PASSWORD, db=DB_CONN.DBNAME, charset='utf8mb4'),
        max_idle_connections=50,
        max_recycle_sec=3,
        max_open_connections=100,
    )
    return pool_db

@gen.coroutine
def main():
    conn = create_pool()
    cur = yield conn.begin()
    try:
        yield cur.execute('insert into temple_text(words)values(99999)',())
        print cur._executed
        #sleep(100)
        #yield cur.execute('insert into test(id,abc)values(99999)',())
        yield cur.commit()
    except Exception,e:
        yield cur.rollback()
        print str(e)
    

    
if __name__=='__main__':
    try:
        ioloop.IOLoop.current().run_sync(main)
    except Exception,e:
        print str(e)

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐