X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fdakdb%2F__init__.py;h=a35616dd4c12ad4e1b10d8abad9aaa2ebbda4bc0;hb=98d086ddda3772fb58c1bfa97478e8044596b569;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hpb=af486e867c2809515c09ae4f854a95355112010e;p=dak.git diff --git a/dak/dakdb/__init__.py b/dak/dakdb/__init__.py index e69de29b..a35616dd 100644 --- a/dak/dakdb/__init__.py +++ b/dak/dakdb/__init__.py @@ -0,0 +1,33 @@ +""" +Database update scripts for usage with B{dak update-db} + +@contact: Debian FTP Master +@copyright: 2008 Michael Casadevall +@license: GNU General Public License version 2 or later + +Update scripts have to C{import psycopg2} and +C{from daklib.dak_exceptions import DBUpdateError}. + +There has to be B{at least} the function C{do_update(self)} to be +defined. It should take all neccessary steps to update the +database. If the update fails the changes have to be rolled back and the +C{DBUpdateError} exception raised to properly halt the execution of any +other update. + +Example:: + def do_update(self): + print "Doing something" + + try: + c = self.db.cursor() + c.execute("SOME SQL STATEMENT") + self.db.commit() + + except psycopg2.ProgrammingError, msg: + self.db.rollback() + raise DBUpdateError, "Unable to do whatever, rollback issued. Error message : %s" % (str(msg)) + +This function can do whatever it wants and use everything from dak and +daklib. + +"""