X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=inline;f=daklib%2Fdbconn.py;h=45e000d395fbf104a8331004e7a95451114ba1f6;hb=e0d8e7998f4ad7a88ff7e839cdf86080425a69ea;hp=72b072c1f83bd9f07627bbf87f6f104d6c66b5bb;hpb=9fdc2e2dd3436a5663133ca35f3f4d39b35303a3;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 72b072c1..45e000d3 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -40,8 +40,10 @@ import traceback from inspect import getargspec +import sqlalchemy from sqlalchemy import create_engine, Table, MetaData from sqlalchemy.orm import sessionmaker, mapper, relation +from sqlalchemy import types as sqltypes # Don't remove this, we re-export the exceptions to scripts which import us from sqlalchemy.exc import * @@ -55,6 +57,22 @@ from textutils import fix_maintainer ################################################################################ +# Patch in support for the debversion field type so that it works during +# reflection + +class DebVersion(sqltypes.Text): + def get_col_spec(self): + return "DEBVERSION" + +sa_major_version = sqlalchemy.__version__[0:3] +if sa_major_version == "0.5": + from sqlalchemy.databases import postgres + postgres.ischema_names['debversion'] = DebVersion +else: + raise Exception("dak isn't ported to SQLA versions != 0.5 yet. See daklib/dbconn.py") + +################################################################################ + __all__ = ['IntegrityError', 'SQLAlchemyError'] ################################################################################