add query timeout to execute and executemany methods#88
add query timeout to execute and executemany methods#88fernandezpablo85 wants to merge 6 commits intobaztian:masterfrom
Conversation
Don't fail on dates before 1900 on Python < 3
|
@baztian ? |
baztian
left a comment
There was a problem hiding this comment.
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? |
baztian
left a comment
There was a problem hiding this comment.
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?
|
|
||
| # 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.
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.
| libs = [ libs ] | ||
| else: | ||
| libs = [] | ||
| jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs) |
There was a problem hiding this comment.
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
PreparedStatementjdbc docs:This changes allow the user to specify a
query_timeoutin seconds.