summaryrefslogtreecommitdiff
path: root/oslo_db/sqlalchemy/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'oslo_db/sqlalchemy/utils.py')
-rw-r--r--oslo_db/sqlalchemy/utils.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/oslo_db/sqlalchemy/utils.py b/oslo_db/sqlalchemy/utils.py
index 120b129..ac027ca 100644
--- a/oslo_db/sqlalchemy/utils.py
+++ b/oslo_db/sqlalchemy/utils.py
@@ -1139,6 +1139,36 @@ def get_non_innodb_tables(connectable, skip_tables=('migrate_version',
return [i[0] for i in noninnodb]
+def get_non_ndbcluster_tables(connectable, skip_tables=None):
+ """Get a list of tables which don't use MySQL Cluster (NDB) storage engine.
+
+ :param connectable: a SQLAlchemy Engine or Connection instance
+ :param skip_tables: a list of tables which might have a different
+ storage engine
+ """
+ query_str = """
+ SELECT table_name
+ FROM information_schema.tables
+ WHERE table_schema = :database AND
+ engine != 'ndbcluster'
+ """
+
+ params = {}
+ if skip_tables:
+ params = dict(
+ ('skip_%s' % i, table_name)
+ for i, table_name in enumerate(skip_tables)
+ )
+
+ placeholders = ', '.join(':' + p for p in params)
+ query_str += ' AND table_name NOT IN (%s)' % placeholders
+
+ params['database'] = connectable.engine.url.database
+ query = text(query_str)
+ nonndbcluster = connectable.execute(query, **params)
+ return [i[0] for i in nonndbcluster]
+
+
class NonCommittingConnectable(object):
"""A ``Connectable`` substitute which rolls all operations back.