"Fossies" - the Fresh Open Source Software Archive

Member "PURELIB/trac/upgrades/db27.py" (27 Aug 2019, 1022 Bytes) of package /windows/misc/Trac-1.4.win32.exe:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "db27.py": 1.3.5_vs_1.3.6.

    1 # -*- coding: utf-8 -*-
    2 #
    3 # Copyright (C) 2012-2019 Edgewall Software
    4 # All rights reserved.
    5 #
    6 # This software is licensed as described in the file COPYING, which
    7 # you should have received as part of this distribution. The terms
    8 # are also available at https://trac.edgewall.org/wiki/TracLicense.
    9 #
   10 # This software consists of voluntary contributions made by many
   11 # individuals. For the exact contribution history, see the revision
   12 # history and logs, available at https://trac.edgewall.org/.
   13 
   14 from trac.db import Table, Column, DatabaseManager
   15 
   16 def do_upgrade(env, ver, cursor):
   17     """Modify the cache table to use an integer id."""
   18     # No need to keep the previous content
   19     cursor.execute("DROP TABLE cache")
   20 
   21     table = Table('cache', key='id')[
   22         Column('id', type='int'),
   23         Column('generation', type='int'),
   24         Column('key'),
   25     ]
   26     db_connector, _ = DatabaseManager(env).get_connector()
   27     for stmt in db_connector.to_sql(table):
   28         cursor.execute(stmt)