added support for reusing connections

This commit is contained in:
Miroslav Stampar 2010-03-30 13:52:47 +00:00
parent f0729565a9
commit 1973024ebf
7 changed files with 37 additions and 6 deletions

View File

@ -45,7 +45,10 @@ class Connector(GenericConnector):
def __init__(self):
GenericConnector.__init__(self)
def connect(self):
def connect(self, reuse=True):
if reuse and self.connector:
return
self.initConnection()
try:
@ -89,4 +92,5 @@ class Connector(GenericConnector):
def close(self):
self.cursor.close()
self.connector.close()
self.closed()

View File

@ -43,7 +43,10 @@ class Connector(GenericConnector):
def __init__(self):
GenericConnector.__init__(self)
def connect(self):
def connect(self, reuse=True):
if reuse and self.connector:
return
self.initConnection()
try:
@ -83,3 +86,4 @@ class Connector(GenericConnector):
def close(self):
self.cursor.close()
self.connector.close()
self.closed()

View File

@ -47,7 +47,10 @@ class Connector(GenericConnector):
def __init__(self):
GenericConnector.__init__(self)
def connect(self):
def connect(self, reuse=True):
if reuse and self.connector:
return
self.initConnection()
try:
@ -87,3 +90,4 @@ class Connector(GenericConnector):
def close(self):
self.cursor.close()
self.connector.close()
self.closed()

View File

@ -46,7 +46,10 @@ class Connector(GenericConnector):
def __init__(self):
GenericConnector.__init__(self)
def connect(self):
def connect(self, reuse=True):
if reuse and self.connector:
return
self.initConnection()
self.__dsn = cx_Oracle.makedsn(self.hostname, self.port, self.db)
@ -91,3 +94,4 @@ class Connector(GenericConnector):
def close(self):
self.cursor.close()
self.connector.close()
self.closed()

View File

@ -46,7 +46,10 @@ class Connector(GenericConnector):
def __init__(self):
GenericConnector.__init__(self)
def connect(self):
def connect(self, reuse=True):
if reuse and self.connector:
return
self.initConnection()
try:
@ -86,3 +89,4 @@ class Connector(GenericConnector):
def close(self):
self.cursor.close()
self.connector.close()
self.closed()

View File

@ -47,7 +47,10 @@ class Connector(GenericConnector):
def __init__(self):
GenericConnector.__init__(self)
def connect(self):
def connect(self, reuse=True):
if reuse and self.connector:
return
self.initConnection()
try:
@ -87,3 +90,4 @@ class Connector(GenericConnector):
def close(self):
self.cursor.close()
self.connector.close()
self.closed()

View File

@ -46,6 +46,13 @@ class Connector:
infoMsg = "connection to %s server %s" % (conf.dbms, self.hostname)
infoMsg += ":%d established" % self.port
logger.info(infoMsg)
def closed(self):
self.connector = None
self.cursor = None
infoMsg = "connection to %s server %s" % (conf.dbms, self.hostname)
infoMsg += ":%d closed" % self.port
logger.info(infoMsg)
def connect(self):
errMsg = "'connect' method must be defined "