Created
January 30, 2015 19:50
-
-
Save Calzzetta/59e4bb50edd8ac30a6d9 to your computer and use it in GitHub Desktop.
Connection pool with cx_Oracle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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