Mercurial > hg > ltpdarepo
changeset 15:3d6c57b24e72
Add logging to upgrade procedure.
author | Daniele Nicolodi <daniele@grinta.net> |
---|---|
date | Mon, 27 Jun 2011 13:49:12 +0200 |
parents | 29aa9cbb321c |
children | 23bfe8ed4163 |
files | src/ltpdarepo/upgrade.py |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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