From c4466cb4dcf194f634b6fe855f5e5fad09e70df1 Mon Sep 17 00:00:00 2001 From: Elrond Date: Thu, 13 Dec 2012 12:35:27 +0100 Subject: Add inspect_table. In our current scheme of migrations, we reflect the current sql schema into an SQLAlchemy schema. So let's have a tool function for this. --- mediagoblin/db/sql/migration_tools.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'mediagoblin/db/sql/migration_tools.py') diff --git a/mediagoblin/db/sql/migration_tools.py b/mediagoblin/db/sql/migration_tools.py index ee84e06f..e5380a3b 100644 --- a/mediagoblin/db/sql/migration_tools.py +++ b/mediagoblin/db/sql/migration_tools.py @@ -15,6 +15,7 @@ # along with this program. If not, see . from mediagoblin.tools.common import simple_printer +from sqlalchemy import Table class MigrationManager(object): @@ -261,3 +262,9 @@ def assure_migrations_table_setup(db): if not MigrationData.__table__.exists(db.bind): MigrationData.metadata.create_all( db.bind, tables=[MigrationData.__table__]) + + +def inspect_table(metadata, table_name): + """Simple helper to get a ref to an already existing table""" + return Table(table_name, metadata, autoload=True, + autoload_with=metadata.bind) -- cgit v1.2.3