Python 中存储过程的执行时间太长
我希望有人可以帮助我解决某个问题...
这是我拥有的功能示例:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论