-
Notifications
You must be signed in to change notification settings - Fork 148
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
add query timeout to execute and executemany methods #88
Open
fernandezpablo85
wants to merge
6
commits into
baztian:master
Choose a base branch
from
fernandezpablo85:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ef7ad4e
Merge pull request #35 from baztian/bugfix/ancient-date
baztian 8850cf9
Fix development notes on how to publish a new release.
baztian e99a05d
Bump version: 1.1.0 → 1.1.1
baztian b04ab61
add query timeout to execute and executemany methods
2b4a7e5
accidentally removed line
5c7fee9
timeout test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[bumpversion] | ||
current_version = 1.1.0 | ||
current_version = 1.1.1 | ||
commit = True | ||
tag = True | ||
|
||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
# License along with JayDeBeApi. If not, see | ||
# <http://www.gnu.org/licenses/>. | ||
|
||
__version_info__ = (1, 1, 0) | ||
__version_info__ = (1, 1, 1) | ||
__version__ = ".".join(str(i) for i in __version_info__) | ||
|
||
import datetime | ||
|
@@ -347,7 +347,7 @@ def TimestampFromTicks(ticks): | |
return apply(Timestamp, time.localtime(ticks)[:6]) | ||
|
||
# DB-API 2.0 Module Interface connect constructor | ||
def connect(jclassname, url, driver_args=None, jars=None, libs=None): | ||
def connect(jclassname, url, driver_args=None, jars=None, libs=None, timeout=None): | ||
"""Open a connection to a database using a JDBC driver and return | ||
a Connection instance. | ||
|
||
|
@@ -378,8 +378,7 @@ def connect(jclassname, url, driver_args=None, jars=None, libs=None): | |
libs = [ libs ] | ||
else: | ||
libs = [] | ||
jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs) | ||
return Connection(jconn, _converters) | ||
return Connection(jconn, _converters, timeout) | ||
|
||
# DB-API 2.0 Connection Object | ||
class Connection(object): | ||
|
@@ -395,10 +394,11 @@ class Connection(object): | |
DataError = DataError | ||
NotSupportedError = NotSupportedError | ||
|
||
def __init__(self, jconn, converters): | ||
def __init__(self, jconn, converters, timeout=None): | ||
self.jconn = jconn | ||
self._closed = False | ||
self._converters = converters | ||
self._timeout = timeout | ||
|
||
def close(self): | ||
if self._closed: | ||
|
@@ -419,7 +419,7 @@ def rollback(self): | |
_handle_sql_exception() | ||
|
||
def cursor(self): | ||
return Cursor(self, self._converters) | ||
return Cursor(self, self._converters, self._timeout) | ||
|
||
# DB-API 2.0 Cursor Object | ||
class Cursor(object): | ||
|
@@ -430,9 +430,10 @@ class Cursor(object): | |
_rs = None | ||
_description = None | ||
|
||
def __init__(self, connection, converters): | ||
def __init__(self, connection, converters, timeout=None): | ||
self._connection = connection | ||
self._converters = converters | ||
self._timeout = timeout | ||
|
||
@property | ||
def description(self): | ||
|
@@ -486,9 +487,12 @@ def _close_last(self): | |
|
||
def _set_stmt_parms(self, prep_stmt, parameters): | ||
for i in range(len(parameters)): | ||
# print (i, parameters[i], type(parameters[i])) | ||
prep_stmt.setObject(i + 1, parameters[i]) | ||
|
||
# https://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#setQueryTimeout(int) | ||
if self._timeout is not None: | ||
prep_stmt.setQueryTimeout(int(self._timeout)) # unit: seconds | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to have it fail fast: Put the conversion into the connect method and only pass down the integer so you don't need a conversion down here. |
||
|
||
def execute(self, operation, parameters=None): | ||
if self._connection._closed: | ||
raise Error() | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
setup( | ||
#basic package data | ||
name = 'JayDeBeApi', | ||
version = '1.1.0', | ||
version = '1.1.1', | ||
author = 'Bastian Bowe', | ||
author_email = '[email protected]', | ||
license = 'GNU LGPL', | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does the code work without this line?