Skip to content

Instantly share code, notes, and snippets.

@Calzzetta
Created January 30, 2015 19:50
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save Calzzetta/59e4bb50edd8ac30a6d9 to your computer and use it in GitHub Desktop.
Save Calzzetta/59e4bb50edd8ac30a6d9 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