1. <small id='rqK7O'></small><noframes id='rqK7O'>

      <legend id='rqK7O'><style id='rqK7O'><dir id='rqK7O'><q id='rqK7O'></q></dir></style></legend>
      • <bdo id='rqK7O'></bdo><ul id='rqK7O'></ul>

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

        Python MYSQL 更新语句

        时间:2023-05-23
      1. <legend id='4EGxE'><style id='4EGxE'><dir id='4EGxE'><q id='4EGxE'></q></dir></style></legend>

              <tbody id='4EGxE'></tbody>

            <small id='4EGxE'></small><noframes id='4EGxE'>

            • <bdo id='4EGxE'></bdo><ul id='4EGxE'></ul>

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

                  本文介绍了Python MYSQL 更新语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在尝试使这个 Python MYSQL 更新语句正确(带变量):

                  I'm trying to get this Python MYSQL update statement correct(With Variables):

                  cursor.execute ("UPDATE tblTableName SET Year=%s" % Year ", Month=%s" % Month ", Day=%s" % Day ", Hour=%s" % Hour ", Minute=%s" Minute "WHERE Server=%s " % ServerID)   
                  

                  有什么想法我哪里出错了吗?

                  Any ideas where I'm going wrong?

                  推荐答案

                  应该是:

                  cursor.execute ("""
                     UPDATE tblTableName
                     SET Year=%s, Month=%s, Day=%s, Hour=%s, Minute=%s
                     WHERE Server=%s
                  """, (Year, Month, Day, Hour, Minute, ServerID))
                  

                  您可以通过基本的字符串操作来实现,

                  You can also do it with basic string manipulation,

                  cursor.execute ("UPDATE tblTableName SET Year=%s, Month=%s, Day=%s, Hour=%s, Minute=%s WHERE Server='%s' " % (Year, Month, Day, Hour, Minute, ServerID))
                  

                  但是这种方式是不鼓励的,因为它会让您对 SQL 注入持开放态度.因为以正确的方式tm来做这件事很容易(和类似).正确地做.

                  but this way is discouraged because it leaves you open for SQL Injection. As it's so easy (and similar) to do it the right waytm. Do it correctly.

                  唯一需要注意的是,某些数据库后端不遵循相同的字符串替换约定(想到 SQLite).

                  The only thing you should be careful, is that some database backends don't follow the same convention for string replacement (SQLite comes to mind).

                  这篇关于Python MYSQL 更新语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:MySQL 导出到 outfile:CSV 转义字符 下一篇:MySQL 加载数据 infile - 加速?

                  相关文章

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

                    1. <small id='iWAXL'></small><noframes id='iWAXL'>

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