Skip to content
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

Allow us to change the cursor's timeout #1217

Open
hb2638 opened this issue May 11, 2023 · 2 comments
Open

Allow us to change the cursor's timeout #1217

hb2638 opened this issue May 11, 2023 · 2 comments

Comments

@hb2638
Copy link

hb2638 commented May 11, 2023

Please first make sure you have looked at:

Environment

To diagnose, we usually need to know the following, including version numbers. On Windows, be
sure to specify 32-bit Python or 64-bit:

  • Python: 3.11
  • pyodbc: 4.0.39
  • OS: Windows
  • DB: SQL Server
  • driver: SQL Server ODBC Driver

Issue

The cursor's SQL_ATTR_QUERY_TIMEOUT gets applied when the cursor is instaniated and it uses whatever timeout the connection has at that time... ok. But the problem is there's no way to change this. I thought changing the connection's timeout would do it but that's not the case after looking at the source code.

I'm running stuff inside AWS lambda and I want to the timeout to be a few seconds less than the "remaining execution time". Lambda lets you run for up to 15 minutes, so I want my query time to be reflective of the remaining time.

Is there at least a workaround where I can call SQLSetStmtAttr with SQL_ATTR_QUERY_TIMEOUT on the cursor object from python?

@v-chojas
Copy link
Contributor

Must you use same cursor object, or is it acceptable to recreate it?

@hb2638
Copy link
Author

hb2638 commented May 11, 2023

I think I can get away with recreating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants