-
Notifications
You must be signed in to change notification settings - Fork 0
/
Oracle.py
33 lines (28 loc) · 975 Bytes
/
Oracle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Created on Sept 24, 2015
@author: del20"""
class Oracle:
def __init__(self, host, port, SID, user, password, db=None):
self.host = host
self.port = port
self.SID = SID
self.user = user
self.password = password
self.db = db
self.connection = None
def getConnection(self):
if not self.connection:
import cx_Oracle
dsn_tns = cx_Oracle.makedsn(self.host, self.port, self.SID)
self.connection = cx_Oracle.connect(self.user, self.password, dsn_tns)
return self.connection
def getFullyQualifyTableName(self, tableName):
tableFullName = tableName
if self.db:
tableFullName = self.db + "." + tableName
print tableFullName
return tableFullName
def close(self):
if (self.connection):
self.connection.close()
def escape(self, tableName):
return tableName