import MySQLdb
from DBUtils.PooledDB import PooledDB
pool = PooledDB(MySQLdb,15,host='localhost',user='test',passwd='test',db='crawl',port=3306) #15为连接池里的最少连接数
conn = pool.connection()
cur=conn.cursor()
SQL="select * from mytable limit 5"
r=cur.execute(SQL)
r=cur.fetchall()
for item in r:
print item[0]
cur.close()
conn.close()
from DBUtils.PooledDB import PooledDB
pool = PooledDB(MySQLdb,15,host='localhost',user='test',passwd='test',db='crawl',port=3306) #15为连接池里的最少连接数
conn = pool.connection()
cur=conn.cursor()
SQL="select * from mytable limit 5"
r=cur.execute(SQL)
r=cur.fetchall()
for item in r:
print item[0]
cur.close()
conn.close()