python数据库连接池


python数据库连接池
import psycopg2
import psycopg2.pool
dbpool=psycopg2.pool.PersistentConnectionPool(1,1,dbname='postgis',user='postgres',host='127.0.0.1',password='1',port='5432')
conn=dbpool.getconn()
cursor=conn.cursor()
sqlstr="select name,type,state from wy"
cursor.execute(sqlstr)
rows=cursor.fetchall()
for row in rows:
   print "name",row[0]
   print "type",row[1]
   print "state",row[2]
   print "***"
dbpool.putconn(conn)

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM