1234567891011121314151617181920212223 |
- '''
- Created on 2018年12月19日
- @author: User
- '''
- import psycopg2
- from DBUtils.PooledDB import PooledDB
- pool = None
- def getConnection():
- global pool
- if pool is None:
- pool = PooledDB(psycopg2, 10,dbname="BiddingKG", host="192.168.2.101",user="postgres",password="postgres",port="5432")
- return pool.connection()
- if __name__=="__main__":
- conn = getConnection()
- cursor = conn.cursor()
- cursor.execute(" select 1")
- print(cursor.fetchall()[0][0])
|