Python 中存储过程的执行时间太长

发布于 2025-01-14 04:14:16 字数 537 浏览 5 评论 0原文

我希望有人可以帮助我解决某个问题...

这是我拥有的功能示例:

from pyodbc import connect
from pandas import read_sql

conn = connect('Driver={SQL Server};SERVER=Server_Name;DATABASE=Database_Name;Trusted_Connection=Yes', autocommit=True)
current_date = datetime.now().date().strftime("%Y-%m-%d")
query1 = f"exec [dbo].[Stored_Precedure_Name] @param1 = 1, @param2= N'{current_date}'"
df = read_sql(query1, conn)

问题是该请求需要大约 7 分钟才能加载。但如果我在 SSMS 中执行它,加载只需要几秒钟。

我不知道为什么与 SSMS 相比,Python 需要这么长时间才能加载。 有谁知道为什么会这样?任何想法表示赞赏。

I was hoping someone could help me with a certain issue...

Here's a sample of a funtion I have:

from pyodbc import connect
from pandas import read_sql

conn = connect('Driver={SQL Server};SERVER=Server_Name;DATABASE=Database_Name;Trusted_Connection=Yes', autocommit=True)
current_date = datetime.now().date().strftime("%Y-%m-%d")
query1 = f"exec [dbo].[Stored_Precedure_Name] @param1 = 1, @param2= N'{current_date}'"
df = read_sql(query1, conn)

The problem is that this reqest takes about 7 minutes to load. But if I execute it in SSMS, it only takes a few seconds to load.

I have no idea why it takes Python so long to load compared to SSMS.
Does anybody know why is it so? Any ideas appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文