Last active
September 26, 2015 18:19
-
-
Save cemremengu/11a04f60db95f6595144 to your computer and use it in GitHub Desktop.
cx_Oracle Wrapper
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 | |
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