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/

  • 相关阅读:
    background及background-size
    -ms-,-moz-,-webkit-,-o-含义
    &:first-of-type含义
    ES6的Promise对象
    LightOJ 1029 Civil and Evil Engineer最小生成树和最大生成树
    快速幂模板
    poj2965 The Pilots Brothers' refrigerator 枚举或DFS
    poj1753Flip Game(枚举+DFS)
    POJ 1751Highways
    HDU 1875 畅通工程再续 prim模板题
  • 原文地址:https://www.cnblogs.com/lexus/p/1806106.html
Copyright © 2011-2022 走看看