Skip to content

Instantly share code, notes, and snippets.

@cemremengu
Last active September 26, 2015 18:19
Show Gist options
  • Save cemremengu/11a04f60db95f6595144 to your computer and use it in GitHub Desktop.
Save cemremengu/11a04f60db95f6595144 to your computer and use it in GitHub Desktop.
cx_Oracle Wrapper
import cx_Oracle
class OracleWrapper(object):
"""
A class for handling db operations
"""
def __init__(self, constring):
self.constring = constring.strip()
self.db_connection = cx_Oracle.connect(constring)
self.cursor = self.db_connection.cursor()
def execute(self, sqlstr):
"""
Use for anything other than select statements
such as insert
"""
self.cursor.execute(sqlstr)
self.db_connection.commit()
def select(self, sqlstr):
"""
Use only for select statement
"""
self.cursor.execute(sqlstr)
return self.cursor.fetchall()
def close_connection(self):
"""
Closes the db connection
"""
self.cursor.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment