diff options
| author | Boris Pavlovic <boris@pavlovic.me> | 2013-05-12 01:05:51 +0400 |
|---|---|---|
| committer | Boris Pavlovic <boris@pavlovic.me> | 2013-05-13 17:53:07 +0400 |
| commit | 4adc3f13da943e819ad52b212c8ad69edf11bc29 (patch) | |
| tree | dc2ba19c2071c98c1b401e833fd0b2458d59ac0d /nova/db | |
| parent | 5dba32a23e67341bfdc03a00781ab491238e21f4 (diff) | |
Move get_table() from test_migrations to sqlalchemy.utils
get_table() is very useful in different places. So it is better
to move it from test_migrations to sqlalchemy.utils.
blueprint db-common-migration-and-utils
Change-Id: I1191b95aede8688a2b38ac4dd0f2e9108dda1559
Diffstat (limited to 'nova/db')
| -rw-r--r-- | nova/db/sqlalchemy/utils.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/nova/db/sqlalchemy/utils.py b/nova/db/sqlalchemy/utils.py index ccca9cb9d..f0eece661 100644 --- a/nova/db/sqlalchemy/utils.py +++ b/nova/db/sqlalchemy/utils.py @@ -33,6 +33,16 @@ from nova.openstack.common import timeutils LOG = logging.getLogger(__name__) +def get_table(engine, name): + """Returns an sqlalchemy table dynamically from db. + + Needed because the models don't work for us in migrations + as models will be far out of sync with the current data.""" + metadata = MetaData() + metadata.bind = engine + return Table(name, metadata, autoload=True) + + class InsertFromSelect(UpdateBase): def __init__(self, table, select): self.table = table |
