-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
close connection in case of DatabaseError #173
Conversation
😱, that was quick. Thanks, I'll take a look |
print(colored('Your query raised DatabaseError:', "red", self.ct)) | ||
print(colored(str(exc), "red", self.ct)) | ||
self.con.close() | ||
if self.loading_bar: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have it somewhere, but is the connection reopen after closing it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I checked the next step after closing/canceling connection is pinging the database to check the connection. If the ping comes back as False, the code will connect to database again. Try to run invalid query and then a valid one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh i see, yes, that's what i meant. great!
(type, value, traceback) = sys.exc_info() | ||
self.con.cancel() | ||
t2 = time.time() | ||
|
||
(type, value, traceback) = sys.exc_info() | ||
self.con.cancel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't these lines duplicated? they don't show are being removed
print(colored('Your query raised DatabaseError:', "red", self.ct)) | ||
print(colored(str(exc), "red", self.ct)) | ||
self.con.close() | ||
if self.loading_bar: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh i see, yes, that's what i meant. great!
Fixes #130
@mgckind PTAL
Code catches the cx_Oracle.Database error due to incorrect syntax in query and closes the connection instead of trying to cancel it.
Cancelling connection causes it to hang, closing it allows to go around it.