zoukankan      html  css  js  c++  java
  • sqlite in python

    在PySQLite中的文档 http://docs.python.org/library/sqlite3.html?highlight=pysqlite#controlling-transactions

    By default, the sqlite3 module opens transactions implicitly before a Data Modification Language (DML) statement (i.e. INSERT/UPDATE/DELETE/REPLACE), and commits transactions implicitly before a non-DML, non-query statement (i. e. anything other than SELECT or the aforementioned).
    默认情况下, sqlite3模块,在每次数据修改语句(DML)(比如 INSERT/UPDATE/DELETE/REPLACE)中,都隐含打开一个事务, 并在 非数据修改语句(比如 DELETE等) 之前, 隐含地提交这个事务

    所以, python中, 只需要在在connection 被close前, commit一次就好了, 不要每次execute都commit

     
    This method commits the current transaction. If you don’t call this method, anything you did since the last call to commit() is not visible from other database connections. If you wonder why you don’t see the data you’ve written to the database, please check you didn’t forget to call this method.

    如果不调用commit(),数据对其他的进程的数据库连接是不可见的

    如果执行insert语句后, 又执行了select, 那么就不必commit了,因为会自动commit一次

    reference:http://zhiwei.li/text/2010/08/sqlite%E6%8F%92%E5%85%A5%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96/

  • 相关阅读:
    Asp.Net 之 前台绑定常用总结
    http无状态
    整理Py小demo
    RawURL
    整理的笔记
    单例模式
    DevExpress v18.1新版亮点——Analytics Dashboard篇(一)
    DevExpress v18.1新版亮点——Reporting篇(四)
    MyEclipse教程:使用UML创建模块库——第二部分(一)
    DevExpress v18.1新版亮点——Reporting篇(三)
  • 原文地址:https://www.cnblogs.com/lexus/p/1806106.html
Copyright © 2011-2022 走看看