-
Notifications
You must be signed in to change notification settings - Fork 149
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
base: master
Are you sure you want to change the base?
Conversation
Don't fail on dates before 1900 on Python < 3
@baztian ? |
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.
Thanks for the PR. And sorry for not answering so long.
@baztian done. Let me know what you think. |
Thanks again. I don't understand why timeout is extracted from the driver url. Shouldn't the driver already take care of the timeouts if you specify such an url. It is definitely passed to the driver? |
Sorry. You're right. Will send an updated patch later today. |
b5cca67
to
b04ab61
Compare
@baztian I think that is what you originally meant, right? |
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.
It would be nice to have at least one test that makes sure the code works with a timeout provided. (I think asserting that timeout works is a bit too complicated) Can you add a test please?
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 comment
The 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.
jaydebeapi/__init__.py
Outdated
@@ -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) |
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?
One more thought: I know I asked you to change it to be a connection parameter to stay as close to DB-API spec as possible. But I also remember the discussion in #29 where the same options exist. |
@baztian I'm having a tough time setting up the test environment. I created a test that passes a timeout and sees that at least the statement succeeds. Hopefully the CI will run it. I was thinking of a more thorough test modifying the |
Till this PR gets released, we can do this
or use |
21d2b3e
to
d31d9a9
Compare
+1 |
From the
PreparedStatement
jdbc docs:This changes allow the user to specify a
query_timeout
in seconds.