Skip to content

Add configurable query timeout via MSSQL_QUERY_TIMEOUT environment variable - #41

Open
MWC914 wants to merge 2 commits into
RichardHan:mainfrom
MWC914:main
Open

Add configurable query timeout via MSSQL_QUERY_TIMEOUT environment variable#41
MWC914 wants to merge 2 commits into
RichardHan:mainfrom
MWC914:main

Conversation

@MWC914

@MWC914 MWC914 commented Jun 9, 2026

Copy link
Copy Markdown

Fixes #40

Without a query timeout, queries that run longer than expected execute
indefinitely with no automatic termination.

Changes:

  • Added config["timeout"] = int(os.getenv("MSSQL_QUERY_TIMEOUT", "300"))
    to get_db_config() so the timeout flows through to all three
    pymssql.connect() calls automatically
  • Added pymssql.OperationalError handler in call_tool() to return
    a clean timeout error message rather than a generic exception
  • Documented MSSQL_QUERY_TIMEOUT in README under Optional Settings

Defaults to 300 seconds. Tested on Windows with Windows Authentication.

MWC914 added 2 commits June 9, 2026 07:49
Fixes RichardHan#40

Adds timeout to get_db_config() so all pymssql.connect() calls 
inherit a per-query timeout. Defaults to 300 seconds. Configurable 
via MSSQL_QUERY_TIMEOUT environment variable.

Adds pymssql.OperationalError handler in call_tool() for a clean 
timeout error message.
Added MSSQL_QUERY_TIMEOUT to the Optional Settings section so users 
know the timeout is configurable without having to read the source code.
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

Successfully merging this pull request may close these issues.

No query timeout configured — runaway queries run indefinitely

1 participant