# HG changeset patch # User Daniele Nicolodi # Date 1309175352 -7200 # Node ID 3d6c57b24e72c194a74a4d3a7c05ab7f8fe8ed10 # Parent 29aa9cbb321c3ff8e91e74142a63f44334b05cb3 Add logging to upgrade procedure. diff -r 29aa9cbb321c -r 3d6c57b24e72 src/ltpdarepo/upgrade.py --- a/src/ltpdarepo/upgrade.py Mon Jun 27 13:43:15 2011 +0200 +++ b/src/ltpdarepo/upgrade.py Mon Jun 27 13:49:12 2011 +0200 @@ -1,6 +1,7 @@ -import MySQLdb as db +import logging +from functools import partial -from functools import partial +import MySQLdb as mysql from .config import HOSTNAME, DATABASE, USERNAME, PASSWORD @@ -17,14 +18,16 @@ def upgrade(fromrev=None): - conn = db.connect(host=HOSTNAME, db=DATABASE, user=USERNAME, passwd=PASSWORD) + conn = mysql.connect(host=HOSTNAME, db=DATABASE, user=USERNAME, passwd=PASSWORD) curs = conn.cursor() + logger = logging.getLogger(__name__) # current schema version curs.execute("""SELECT value+0 FROM options WHERE name='version'""") schema = curs.fetchone()[0] if fromrev is not None: + logger.info("force upgrade from v%s", schema) schema = fromrev # filter applicable upgrade steps @@ -34,6 +37,7 @@ for fromr, tor, step in sorted(todo): # run upgrade step + logger.info("upgrading database schema from v%s to v%s", fromr, tor) step(conn) # update schema version