Fix Azure SQL integration: connection caching, lazy import, safe error handling, and Dockerfile hardening#3
Merged
mandeeps merged 2 commits intofeature/azure-sql-integrationfrom Mar 8, 2026
Conversation
…lazy import, and error handling Co-authored-by: mandeeps <3266584+mandeeps@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add Azure SQL integration support to API
Fix Azure SQL integration: connection caching, lazy import, safe error handling, and Dockerfile hardening
Mar 8, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Review feedback on the initial Azure SQL integration surfaced several reliability, security, and correctness issues. This PR addresses all of them.
main.py
pyodbcimport — moved out of module scope into_get_sql_connection()withImportErrorhandling; API now starts cleanly without pyodbc present_blob_container_clientpattern:None= untried,False= permanently disabled, object = live connection; includes a driver-level liveness check (getinfo(2)) with automatic reconnect on stale connectionstype(e).__name__instead of the full exception string, preventing server hostnames, usernames, or connection string fragments from leaking into logscursorinitialized toNonebeforetry;finallyblock guarantees closure;rollback()called on failure; cached connection set toNone(retryable) rather thanFalseon transient execute errorsDockerfile
apt-key addwith modern/etc/apt/keyrings/microsoft.gpg+signed-by=in source list--no-install-recommendsto bothapt-get installcallsaptcache (rm -rf /var/lib/apt/lists/*) after installsca-certificates(required for keyring-based key import)💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.