Skip to content

How do I auto-reconnect to a SQL Server when the connection is lost?  #765

Open
@gpersonnat

Description

@gpersonnat

Describe the bug
I'm running an application that writes data into a SQL server (using Flask), and at some points, the connection to the SQL Server is randomoly lost: 'Not connected to any SQL server".

To Reproduce
Short example reproducing the problem, see http://sscce.org/ for general guidelines.

Expected behavior

Since I can make a good amount of writes to the database before this happens, I expect that there should be way to auto-reconnect to the server when the connection is lost. Is there a simple way I could do this.

Current Behavior
There are random disconnections from the SQL Server, but I want to easily reconnect if connection is lost.
Context (Environment)

  • What are the OS, Python and FreeTDS versions?
  • please include the output of the following command:
    /<path to your python>/python -c "import pymssql; print(pymssql.version_info())"

System:
platform.system() : Darwin
platform.architecture() : ('64bit', '')
platform.libc_ver() : ('', '')
Python:
sys.version : 3.10.1 (v3.10.1:2cd268a3a9, Dec 6 2021, 14:28:59) [Clang 13.0.0 (clang-1300.0.29.3)]
pymssql:
VERSION : (2, 2, 5)
version : 2.2.5
full_version : 2.2.5
dbversion : freetds v1.3.10
_mssql:
VERSION : (2, 2, 5)
version : 2.2.5
full_version : 2.2.5
dbversion : freetds v1.3.10
login_timeout : 60
min_error_severity : 6

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions