<bdo id='H8DQQ'></bdo><ul id='H8DQQ'></ul>
    <legend id='H8DQQ'><style id='H8DQQ'><dir id='H8DQQ'><q id='H8DQQ'></q></dir></style></legend>
    1. <i id='H8DQQ'><tr id='H8DQQ'><dt id='H8DQQ'><q id='H8DQQ'><span id='H8DQQ'><b id='H8DQQ'><form id='H8DQQ'><ins id='H8DQQ'></ins><ul id='H8DQQ'></ul><sub id='H8DQQ'></sub></form><legend id='H8DQQ'></legend><bdo id='H8DQQ'><pre id='H8DQQ'><center id='H8DQQ'></center></pre></bdo></b><th id='H8DQQ'></th></span></q></dt></tr></i><div id='H8DQQ'><tfoot id='H8DQQ'></tfoot><dl id='H8DQQ'><fieldset id='H8DQQ'></fieldset></dl></div>
    2. <small id='H8DQQ'></small><noframes id='H8DQQ'>

      <tfoot id='H8DQQ'></tfoot>

        Python MySql 插入不起作用

        Python MySql Insert not working(Python MySql 插入不起作用)
        <i id='nx4Hp'><tr id='nx4Hp'><dt id='nx4Hp'><q id='nx4Hp'><span id='nx4Hp'><b id='nx4Hp'><form id='nx4Hp'><ins id='nx4Hp'></ins><ul id='nx4Hp'></ul><sub id='nx4Hp'></sub></form><legend id='nx4Hp'></legend><bdo id='nx4Hp'><pre id='nx4Hp'><center id='nx4Hp'></center></pre></bdo></b><th id='nx4Hp'></th></span></q></dt></tr></i><div id='nx4Hp'><tfoot id='nx4Hp'></tfoot><dl id='nx4Hp'><fieldset id='nx4Hp'></fieldset></dl></div>
        • <small id='nx4Hp'></small><noframes id='nx4Hp'>

            <bdo id='nx4Hp'></bdo><ul id='nx4Hp'></ul>
            <tfoot id='nx4Hp'></tfoot>

                <legend id='nx4Hp'><style id='nx4Hp'><dir id='nx4Hp'><q id='nx4Hp'></q></dir></style></legend>

                  <tbody id='nx4Hp'></tbody>

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

                  问题描述

                  我正在使用 python MySQL API 从 python 程序连接到 Mysql 数据库.我从几天就面临一个问题.我无法将记录插入数据库,不知道是什么原因.这是我连接并将记录插入数据库的方式.

                  I am using python MySQL API to connect to Mysql database from python program. I am facing a problem from few days. I am unable to insert records into the database and dont know whats the reason. Here is the way i connect and insert records into the database.

                  db = MySQLdb.connect("localhost","root","padmaramulu","pdfsearch" )
                  cursor = db.cursor()
                  #cursor.execute("""CREATE TABLE IF NOT EXISTS documents (docid INT NOT NULL ,PRIMARY KEY(docid),docname CHAR(30)) engine=innodb""")
                  temp = "hello";number = 2;
                  cursor.execute( 'insert into documents(docid,docname) values("%d","%s")' % (number,temp) )
                  db.close()
                  

                  为什么会这样?

                  推荐答案

                  在关闭连接之前,你应该添加db.commit().

                  Before closing the connection, you should add db.commit().

                  这篇关于Python MySql 插入不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Bogus foreign key constraint fail(虚假外键约束失败)
                  how to get last insert id after insert query in codeigniter active record(如何在codeigniter活动记录中插入查询后获取最后一个插入ID)
                  Force InnoDB to recheck foreign keys on a table/tables?(强制 InnoDB 重新检查表/表上的外键?)
                  How to auto generate migrations with Sequelize CLI from Sequelize models?(如何使用 Sequelize CLI 从 Sequelize 模型自动生成迁移?)
                  Clear MySQL query cache without restarting server(无需重启服务器即可清除 MySQL 查询缓存)
                  ALTER TABLE to add a composite primary key(ALTER TABLE 添加复合主键)
                    1. <small id='TeIdS'></small><noframes id='TeIdS'>

                          <tbody id='TeIdS'></tbody>
                        <legend id='TeIdS'><style id='TeIdS'><dir id='TeIdS'><q id='TeIdS'></q></dir></style></legend>

                          • <bdo id='TeIdS'></bdo><ul id='TeIdS'></ul>

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