Skip to content

Instantly share code, notes, and snippets.

@peterwillcn
Forked from Calzzetta/pool_cx_oracle.py
Created August 10, 2017 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterwillcn/e5cd9bbc8a4bcf59407c3b2281a6f59b to your computer and use it in GitHub Desktop.
Save peterwillcn/e5cd9bbc8a4bcf59407c3b2281a6f59b to your computer and use it in GitHub Desktop.
Connection pool with cx_Oracle
import cx_Oracle
def perform_query(query, bind_variables):
connection = db_pool.acquire()
cursor = connection.cursor()
cursor.execute(query, bind_variables)
result = cursor.fetchall()
cursor.close()
db_pool.release(connection)
return result
db_pool = cx_Oracle.SessionPool('oracle user', 'oracle pass', 'oracle db', 2, 10, 3)
for i in range(100):
result = perform_query('SELECT ...', {'var': 'abc'})
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment