[Buildbot-commits] [Buildbot] #2221: wrap db upgrade scripts in a transaction

Buildbot nobody at buildbot.net
Thu Mar 1 16:19:17 UTC 2012


#2221: wrap db upgrade scripts in a transaction
------------------------+----------------------
Reporter:  dustin       |       Owner:
    Type:  enhancement  |      Status:  closed
Priority:  major        |   Milestone:  0.8.6
 Version:  0.8.5        |  Resolution:  wontfix
Keywords:  database     |
------------------------+----------------------

Comment (by exarkun):

 Actually, SQLite3 does support schema modifications as part of
 transactions:

 {{{
     >>> from sqlite3 import connect
     >>> connection = connect(':memory:', isolation_level=None)
     >>> cursor = connection.cursor()
     >>> cursor.execute('BEGIN IMMEDIATE TRANSACTION')
     <sqlite3.Cursor object at 0x27ac650>
     >>> cursor.execute('CREATE TABLE foo ( a integer, b integer )')
     <sqlite3.Cursor object at 0x27ac650>
     >>> cursor.execute('COMMIT')
     <sqlite3.Cursor object at 0x27ac650>
     >>> cursor.execute('BEGIN IMMEDIATE TRANSACTION')
     <sqlite3.Cursor object at 0x27ac650>
     >>> list(cursor.execute('SELECT * FROM foo'))
     []
     >>> cursor.execute('DROP TABLE foo')
     <sqlite3.Cursor object at 0x27ac650>
     >>> cursor.execute('ROLLBACK')
     <sqlite3.Cursor object at 0x27ac650>
     >>> list(cursor.execute('SELECT * FROM foo'))
     []
     >>>
 }}}

 The pysqlite2 interface to this functionality is rather obtuse, and the
 documentation is very unclear on the matter, which I suppose is why you
 thought it did not work.  At the actual SQLite3 layer the support is quite
 solid, though, and has been present for many years.

-- 
Ticket URL: <http://trac.buildbot.net/ticket/2221#comment:2>
Buildbot <http://buildbot.net/>
Buildbot: build/test automation


More information about the Commits mailing list