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

[Bug] [MSSQL] Unable to connect to MSSQL SERVER 2012 and earlier versions. #2476

Open
2 of 15 tasks
su1234121 opened this issue Mar 17, 2025 · 2 comments
Open
2 of 15 tasks
Labels
bug Something isn't working Waiting for reply

Comments

@su1234121
Copy link

Search before asking

  • I had searched in the issues and found no similar issues.

Operating system information

Linux

Python version information

=3.11

DB-GPT version

main

Related scenes

  • Chat Data
  • Chat Excel
  • Chat DB
  • Chat Knowledge
  • Model Management
  • Dashboard
  • Plugins

Installation Information

Device information

CPU

Models information

Qwen/Qwen2.5-Coder-32B-Instruct
BAAI/bge-large-zh-v1.5
BAAI/bge-reranker-v2-m3

What happened

IF the SQLSERVER version is 2012 or even earlier,it will occur like this:
连接失败: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (172.16.12.74)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (172.16.12.74)\n')

The total info:
2025-03-17 14:42:46 PC-Asus-Su dbgpt_serve.datasource.manages.connector_manager[17187] ERROR Test connection Failure!(pymssql.exceptions.OperationalError) (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (106.14.37.235)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (106.14.37.235)\n')
(Background on this error at: https://sqlalche.me/e/20/e3q8)
2025-03-17 14:42:46 PC-Asus-Su dbgpt_serve.core.schemas[17187] ERROR common_exception_handler catch Exception: success=False err_code='E0003' err_msg="Test connection Failure!(pymssql.exceptions.OperationalError) (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (106.14.37.235)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (106.14.37.235)\n')\n(Background on this error at: https://sqlalche.me/e/20/e3q8)" data=None
INFO: 127.0.0.1:53034 - "POST /api/v2/serve/datasources/test-connection HTTP/1.1" 400 Bad Request
ERROR: Exception in ASGI application

  • Exception Group Traceback (most recent call last):
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_utils.py", line 77, in collapse_excgroups
    | yield
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 186, in call
    | async with anyio.create_task_group() as task_group:
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 767, in aexit
    | raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
    | result = await app( # type: ignore[func-returns-value]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
    | return await self.app(scope, receive, send)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 93, in call
    | await self.simple_response(scope, receive, send, request_headers=headers)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 144, in simple_response
    | await self.app(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call
    | await super().call(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/applications.py", line 113, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in call
    | raise exc
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in call
    | await self.app(scope, receive, _send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 185, in call
    | with collapse_excgroups():
    | File "/home/suc/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/python3.11/contextlib.py", line 158, in exit
    | self.gen.throw(typ, value, traceback)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
    | raise exc
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 187, in call
    | response = await self.dispatch_func(request, call_next)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/util/tracer/tracer_middleware.py", line 49, in dispatch
    | response = await call_next(request)
    | ^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 163, in call_next
    | raise app_exc
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 149, in coro
    | await self.app(scope, receive_or_disconnect, send_no_error)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call
    | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
    | raise exc
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 715, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
    | await route.handle(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
    | await self.app(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
    | await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
    | raise exc
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
    | response = await f(request)
    | ^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
    | raw_response = await run_endpoint_function(
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
    | return await dependant.call(**values)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/datasource/api/endpoints.py", line 233, in test_connection
    | res = await blocking_func_to_async(
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/core/init.py", line 32, in blocking_func_to_async
    | return await _blocking_func_to_async(executor, func, *args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/util/executor_utils.py", line 70, in blocking_func_to_async
    | return await loop.run_in_executor(executor, run_with_context)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    | result = self.fn(*self.args, **self.kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/util/executor_utils.py", line 67, in run_with_context
    | return ctx.run(partial(func, *args, **kwargs))
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/datasource/service/service.py", line 290, in test_connection
    | return self.datasource_manager.test_connection(request)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/datasource/manages/connector_manager.py", line 273, in test_connection
    | raise ValueError(f"Test connection Failure!{str(e)}")
    | ValueError: Test connection Failure!(pymssql.exceptions.OperationalError) (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (106.14.37.235)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (106.14.37.235)\n')
    | (Background on this error at: https://sqlalche.me/e/20/e3q8)
    +------------------------------------

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 93, in call
await self.simple_response(scope, receive, send, request_headers=headers)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 144, in simple_response
await self.app(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call
await super().call(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/applications.py", line 113, in call
await self.middleware_stack(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in call
raise exc
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in call
await self.app(scope, receive, _send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 185, in call
with collapse_excgroups():
File "/home/suc/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/python3.11/contextlib.py", line 158, in exit
self.gen.throw(typ, value, traceback)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
raise exc
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 187, in call
response = await self.dispatch_func(request, call_next)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/util/tracer/tracer_middleware.py", line 49, in dispatch
response = await call_next(request)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 163, in call_next
raise app_exc
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 149, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
raise exc
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
await app(scope, receive, sender)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 715, in call
await self.middleware_stack(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
await route.handle(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
raise exc
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
await app(scope, receive, sender)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/datasource/api/endpoints.py", line 233, in test_connection
res = await blocking_func_to_async(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/core/init.py", line 32, in blocking_func_to_async
return await _blocking_func_to_async(executor, func, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/util/executor_utils.py", line 70, in blocking_func_to_async
return await loop.run_in_executor(executor, run_with_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/util/executor_utils.py", line 67, in run_with_context
return ctx.run(partial(func, *args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/datasource/service/service.py", line 290, in test_connection
return self.datasource_manager.test_connection(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/datasource/manages/connector_manager.py", line 273, in test_connection
raise ValueError(f"Test connection Failure!{str(e)}")
ValueError: Test connection Failure!(pymssql.exceptions.OperationalError) (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (106.14.37.235)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (106.14.37.235)\n')
(Background on this error at: https://sqlalche.me/e/20/e3q8)
2025-03-17 14:42:46 PC-Asus-Su dbgpt.datasource.rdbms.base[17187] INFO Closing RDBMS connector resources...
Exception ignored in: <function BaseConnector.del at 0x7f0e4e57ad40>
Traceback (most recent call last):
File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/datasource/base.py", line 274, in del
self.close()
File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/datasource/rdbms/base.py", line 882, in close
for session in self._sessions:
^^^^^^^^^^^^^^
AttributeError: 'MSSQLConnector' object has no attribute '_sessions'
2025-03-17 15:20:57 PC-Asus-Su dbgpt_serve.datasource.manages.connector_manager[17187] ERROR Test connection Failure!(pymssql.exceptions.OperationalError) (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (172.16.12.74)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (172.16.12.74)\n')
(Background on this error at: https://sqlalche.me/e/20/e3q8)
2025-03-17 15:20:57 PC-Asus-Su dbgpt_serve.core.schemas[17187] ERROR common_exception_handler catch Exception: success=False err_code='E0003' err_msg="Test connection Failure!(pymssql.exceptions.OperationalError) (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (172.16.12.74)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (172.16.12.74)\n')\n(Background on this error at: https://sqlalche.me/e/20/e3q8)" data=None
INFO: 127.0.0.1:60096 - "POST /api/v2/serve/datasources/test-connection HTTP/1.1" 400 Bad Request
ERROR: Exception in ASGI application

  • Exception Group Traceback (most recent call last):
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_utils.py", line 77, in collapse_excgroups
    | yield
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 186, in call
    | async with anyio.create_task_group() as task_group:
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 767, in aexit
    | raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
    | result = await app( # type: ignore[func-returns-value]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
    | return await self.app(scope, receive, send)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 93, in call
    | await self.simple_response(scope, receive, send, request_headers=headers)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 144, in simple_response
    | await self.app(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call
    | await super().call(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/applications.py", line 113, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in call
    | raise exc
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in call
    | await self.app(scope, receive, _send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 185, in call
    | with collapse_excgroups():
    | File "/home/suc/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/python3.11/contextlib.py", line 158, in exit
    | self.gen.throw(typ, value, traceback)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
    | raise exc
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 187, in call
    | response = await self.dispatch_func(request, call_next)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/util/tracer/tracer_middleware.py", line 49, in dispatch
    | response = await call_next(request)
    | ^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 163, in call_next
    | raise app_exc
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 149, in coro
    | await self.app(scope, receive_or_disconnect, send_no_error)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call
    | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
    | raise exc
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 715, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
    | await route.handle(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
    | await self.app(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
    | await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
    | raise exc
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
    | response = await f(request)
    | ^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
    | raw_response = await run_endpoint_function(
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
    | return await dependant.call(**values)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/datasource/api/endpoints.py", line 233, in test_connection
    | res = await blocking_func_to_async(
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/core/init.py", line 32, in blocking_func_to_async
    | return await _blocking_func_to_async(executor, func, *args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/util/executor_utils.py", line 70, in blocking_func_to_async
    | return await loop.run_in_executor(executor, run_with_context)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    | result = self.fn(*self.args, **self.kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/util/executor_utils.py", line 67, in run_with_context
    | return ctx.run(partial(func, *args, **kwargs))
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/datasource/service/service.py", line 290, in test_connection
    | bool: The test result
    | ^^^^^^^^^^^^^^^^^^^
    | File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/datasource/manages/connector_manager.py", line 273, in test_connection
    | raise ValueError(f"Test connection Failure!{str(e)}")
    | ValueError: Test connection Failure!(pymssql.exceptions.OperationalError) (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (172.16.12.74)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (172.16.12.74)\n')
    | (Background on this error at: https://sqlalche.me/e/20/e3q8)
    +------------------------------------

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 93, in call
await self.simple_response(scope, receive, send, request_headers=headers)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 144, in simple_response
await self.app(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call
await super().call(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/applications.py", line 113, in call
await self.middleware_stack(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in call
raise exc
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in call
await self.app(scope, receive, _send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 185, in call
with collapse_excgroups():
File "/home/suc/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/python3.11/contextlib.py", line 158, in exit
self.gen.throw(typ, value, traceback)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
raise exc
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 187, in call
response = await self.dispatch_func(request, call_next)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/util/tracer/tracer_middleware.py", line 49, in dispatch
response = await call_next(request)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 163, in call_next
raise app_exc
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 149, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
raise exc
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
await app(scope, receive, sender)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 715, in call
await self.middleware_stack(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
await route.handle(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
raise exc
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
await app(scope, receive, sender)
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/datasource/api/endpoints.py", line 233, in test_connection
res = await blocking_func_to_async(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/core/init.py", line 32, in blocking_func_to_async
return await _blocking_func_to_async(executor, func, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/util/executor_utils.py", line 70, in blocking_func_to_async
return await loop.run_in_executor(executor, run_with_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/util/executor_utils.py", line 67, in run_with_context
return ctx.run(partial(func, *args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/datasource/service/service.py", line 290, in test_connection
bool: The test result
^^^^^^^^^^^^^^^^^^^
File "/home/suc/DB-GPT/packages/dbgpt-serve/src/dbgpt_serve/datasource/manages/connector_manager.py", line 273, in test_connection
raise ValueError(f"Test connection Failure!{str(e)}")
ValueError: Test connection Failure!(pymssql.exceptions.OperationalError) (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (172.16.12.74)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (172.16.12.74)\n')
(Background on this error at: https://sqlalche.me/e/20/e3q8)
2025-03-17 15:21:00 PC-Asus-Su dbgpt.datasource.rdbms.base[17187] INFO Closing RDBMS connector resources...
Exception ignored in: <function BaseConnector.del at 0x7f0e4e57ad40>
Traceback (most recent call last):
File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/datasource/base.py", line 274, in del
self.close()
File "/home/suc/DB-GPT/packages/dbgpt-core/src/dbgpt/datasource/rdbms/base.py", line 882, in close
for session in self._sessions:
^^^^^^^^^^^^^^
AttributeError: 'MSSQLConnector' object has no attribute '_sessions'

What you expected to happen

connect successfully.
I have figure out the reason,due to the TDS_version,but don't know how to fix this problem.

Image
add the tds_version = "7.0"
for more details at this blog https://zhuanlan.zhihu.com/p/5170716996

How to reproduce

Just install a 2012 or earlier vesion and connect.

Additional context

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@su1234121 su1234121 added bug Something isn't working Waiting for reply labels Mar 17, 2025
@su1234121
Copy link
Author

if the version is 2012 2008r2 2008 even earlier, add tds_version = "7.0" can solve this problem.

@donywud
Copy link

donywud commented Mar 19, 2025

if the version is 2012 2008r2 2008 even earlier, add tds_version = "7.0" can solve this problem.

是的,正解

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Waiting for reply
Projects
None yet
Development

No branches or pull requests

2 participants