Skip to content

Instantly share code, notes, and snippets.

@sant-sh
Forked from Calzzetta/pool_cx_oracle.py
Created December 29, 2018 16:50
Show Gist options
  • Save sant-sh/a0f600de793270c6455830137a868c71 to your computer and use it in GitHub Desktop.
Save sant-sh/a0f600de793270c6455830137a868c71 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