擅长:python、mysql、java
<p>我认为您的代码看起来很好,因为您遵循了<code>pyodbc</code>中的指导原则</p>
<pre><code>//SQL Server format
cursor.execute("exec sp_dosomething(123, 'abc')")
//ODBC format
cursor.execute("{call sp_dosomething(123, 'abc')}")
</code></pre>
<p>从你的评论中你说你看到了这个信息</p>
<blockquote>
<p>`Process finished with exit code 0'</p>
</blockquote>
<p>这意味着一切都成功了好吧。如果程序中发生的任何异常/错误您的程序都应该生成一个带有非零参数的退出代码。在</p>
<p>所以我觉得你的程序运行得很好,而且SP确实被执行了。但是,我怀疑您没有看到更改在您的数据库中生效,这可能是因为您在执行sp之后和关闭与DB的连接之前没有<code>commit()</code>您的更改。在</p>
<p>所以添加<code>conn.commit()</code>如下:</p>
^{pr2}$
<p>编辑:
请尝试使用MsSQL的更新驱动程序</p>
<pre><code> conn = pyodbc.connect(driver = '{SQL Server Native Client 10.0}', server = 'xxxxxx',database = 'xxxx', uid = 'xx', pwd = 'xxxx')
</code></pre>