Skip to content

Instantly share code, notes, and snippets.

@i-amolo
Forked from Calzzetta/pool_cx_oracle.py
Created June 26, 2023 19:44
Show Gist options
  • Save i-amolo/bcd56f25dc56f690840dd7b16371fdaa to your computer and use it in GitHub Desktop.
Save i-amolo/bcd56f25dc56f690840dd7b16371fdaa 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