<bdo id='qy3T0'></bdo><ul id='qy3T0'></ul>

<i id='qy3T0'><tr id='qy3T0'><dt id='qy3T0'><q id='qy3T0'><span id='qy3T0'><b id='qy3T0'><form id='qy3T0'><ins id='qy3T0'></ins><ul id='qy3T0'></ul><sub id='qy3T0'></sub></form><legend id='qy3T0'></legend><bdo id='qy3T0'><pre id='qy3T0'><center id='qy3T0'></center></pre></bdo></b><th id='qy3T0'></th></span></q></dt></tr></i><div id='qy3T0'><tfoot id='qy3T0'></tfoot><dl id='qy3T0'><fieldset id='qy3T0'></fieldset></dl></div>
<legend id='qy3T0'><style id='qy3T0'><dir id='qy3T0'><q id='qy3T0'></q></dir></style></legend>

        <small id='qy3T0'></small><noframes id='qy3T0'>

        <tfoot id='qy3T0'></tfoot>

        Python 中参数查询的语法 (pyodbc)

        时间:2024-04-15
        • <bdo id='tTCsE'></bdo><ul id='tTCsE'></ul>

            <tfoot id='tTCsE'></tfoot>
                <tbody id='tTCsE'></tbody>

                <small id='tTCsE'></small><noframes id='tTCsE'>

                • <i id='tTCsE'><tr id='tTCsE'><dt id='tTCsE'><q id='tTCsE'><span id='tTCsE'><b id='tTCsE'><form id='tTCsE'><ins id='tTCsE'></ins><ul id='tTCsE'></ul><sub id='tTCsE'></sub></form><legend id='tTCsE'></legend><bdo id='tTCsE'><pre id='tTCsE'><center id='tTCsE'></center></pre></bdo></b><th id='tTCsE'></th></span></q></dt></tr></i><div id='tTCsE'><tfoot id='tTCsE'></tfoot><dl id='tTCsE'><fieldset id='tTCsE'></fieldset></dl></div>

                • <legend id='tTCsE'><style id='tTCsE'><dir id='tTCsE'><q id='tTCsE'></q></dir></style></legend>
                  本文介绍了Python 中参数查询的语法 (pyodbc)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将某些处理的结果写入 SQL Server 表中.我的结果存储在列表列表中,其中列表的每个项目都是一个列表.我正在使用参数(6 个参数),但出现以下错误:

                  I am trying to write results of some processing into SQL Server table. My results are store in a list of lists where each item of the list is a list. I am using parameters (6 params) and I am getting the following error:

                  cnxn.execute(sqlStatement, (item[0],item[1],item[2],item[3],item[4],item[5]))pyodbc.ProgrammingError: ('SQL 包含 0 个参数标记,但提供了 6 个参数', 'HY000')

                  cnxn.execute(sqlStatement, (item[0],item[1],item[2],item[3],item[4],item[5])) pyodbc.ProgrammingError: ('The SQL contains 0 parameter markers, but 6 parameters were supplied', 'HY000')

                  这是我的代码

                  sqlStatement = "INSERT INTO CEA_CR (`SessionID`, `Session.Call_TYPE_Assigned`, `Session.Did_Call_Type_happen_on_this_call`, `Session.Was_there_a_system_or_Rep_generated_Memo_that_matches_with_Call_Type` , 'cycle' , 'version')  VALUES (%s, %s, %s, %s ,%s ,%s)"
                  
                  for item in result:
                       wr.writerow(item)
                       cnxn.execute(sqlStatement, (item[0],item[1],item[2],item[3],item[4],item[5]))
                       cnxn.commit()
                  

                  有人知道为什么我的执行失败了吗?

                  Anyone knows why my execution fails ?

                  推荐答案

                  您应该使用 ?作为我相信的参数标记.

                  You should be using ? as parameter markers I believe.

                  你的 sql 应该是这样的:

                  Your sql should probably look like this:

                  sqlStatement = "INSERT INTO CEA_CR (SessionID, Session.Call_TYPE_Assigned, Session.Did_Call_Type_happen_on_this_call, Session.Was_there_a_system_or_Rep_generated_Memo_that_matches_with_Call_Type, cycle, version) VALUES (?, ?, ?, ?, ?, ?)"
                  

                  这篇关于Python 中参数查询的语法 (pyodbc)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:SQL Server - 参数名称中的无效字符 下一篇:将参数绑定到 Oracle 动态 SQL

                  相关文章

                • <small id='3VzNT'></small><noframes id='3VzNT'>

                • <i id='3VzNT'><tr id='3VzNT'><dt id='3VzNT'><q id='3VzNT'><span id='3VzNT'><b id='3VzNT'><form id='3VzNT'><ins id='3VzNT'></ins><ul id='3VzNT'></ul><sub id='3VzNT'></sub></form><legend id='3VzNT'></legend><bdo id='3VzNT'><pre id='3VzNT'><center id='3VzNT'></center></pre></bdo></b><th id='3VzNT'></th></span></q></dt></tr></i><div id='3VzNT'><tfoot id='3VzNT'></tfoot><dl id='3VzNT'><fieldset id='3VzNT'></fieldset></dl></div>
                      <bdo id='3VzNT'></bdo><ul id='3VzNT'></ul>
                      <legend id='3VzNT'><style id='3VzNT'><dir id='3VzNT'><q id='3VzNT'></q></dir></style></legend>
                      <tfoot id='3VzNT'></tfoot>