后端代码微调:SQLserver地址账号变更
This commit is contained in:
+23
-19
@@ -1,25 +1,16 @@
|
||||
from langchain_community.utilities import SQLDatabase
|
||||
from langchain_community.agent_toolkits import create_sql_agent
|
||||
from langchain_community.chat_models.tongyi import ChatTongyi
|
||||
# SQLAlchemy URI
|
||||
uri = "mssql+pyodbc://f8_db_test:APN^QPr!K9@122.114.58.23/f8_db_test?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes&Encrypt=no"
|
||||
|
||||
# 建立数据库对象
|
||||
ssDBLC = SQLDatabase.from_uri(
|
||||
uri,
|
||||
include_tables=["NONGHU_INFO","NONGHU_BLACKLIST",],
|
||||
schema="dbo" # 显式指定 schema
|
||||
)
|
||||
import logging
|
||||
import time
|
||||
from contextlib import contextmanager
|
||||
from sqlalchemy import create_engine, text
|
||||
from sqlalchemy.exc import OperationalError as SQLOperationalError
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
from langchain_community.utilities import SQLDatabase
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.exc import OperationalError as SQLOperationalError
|
||||
|
||||
logger = logging.getLogger("MSSQLPool")
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
|
||||
class MSSQLPool:
|
||||
"""
|
||||
SQL Server 连接池封装
|
||||
@@ -73,10 +64,23 @@ class MSSQLPool:
|
||||
logger.error(f"SQL执行异常: {e}")
|
||||
raise
|
||||
raise SQLOperationalError("无法获取数据库连接,多次重试失败")
|
||||
|
||||
|
||||
|
||||
mssql_pool = MSSQLPool(
|
||||
user="f8_db_test",
|
||||
password="APN^QPr!K9",
|
||||
host="122.114.58.23",
|
||||
database="f8_db_test",
|
||||
user="f8_read",
|
||||
password="www.bbitcn.com",
|
||||
host="f8.api.dev.bbitcn.cn",
|
||||
database="f8_db_dev",
|
||||
)
|
||||
|
||||
# SQLAlchemy URI
|
||||
uri = "mssql+pyodbc://f8_read:www.bbitcn.com@f8.api.dev.bbitcn.cn/f8_db_dev?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes&Encrypt=no"
|
||||
|
||||
# 建立数据库对象
|
||||
ssDBLC = SQLDatabase.from_uri(
|
||||
uri,
|
||||
include_tables=[
|
||||
"NONGHU_INFO",
|
||||
],
|
||||
schema="dbo", # 显式指定 schema
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user