I have an issue with Postgresql psycopg2. I receive the error :
error in executing with exception: connection pool exhausted
My code :
from psycopg2 import pool
import pandas.io.sql as sqlio
import pandas as pd
db = pool.ThreadedConnectionPool(5, 100,host=POSTGRES['host'],
database=POSTGRES['database'],user=POSTGRES['username'],
password=POSTGRES['password'],port=POSTGRES['port'])
try:
sql = "select * from role"
data = sqlio.read_sql_query(sql, db.getconn())
return data.to_json(orient='records')
except Exception as e:
print "error in executing with exception: ", e
return pd.DataFrame({'empty' : []})
and this request should return only 5 rows, but i get this error.
Do you have any idea why i get this error ?
My Postgresql Database (medium instance) is deployed on a public cloud.
Thank you in advance