From 2b6c2d8e06345e64fc450149eedf0ec262f2420a Mon Sep 17 00:00:00 2001 From: jmq Date: Wed, 22 May 2019 10:17:35 -0500 Subject: [PATCH] Fixed a problem with db_setup.py dropping table creation statements Change-Id: I14a0d7ee26ab5ca69a2860bbf2b9006d1b2aab33 --- orm/services/db_setup.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/orm/services/db_setup.py b/orm/services/db_setup.py index 42b3671f..ecec9b46 100644 --- a/orm/services/db_setup.py +++ b/orm/services/db_setup.py @@ -23,7 +23,7 @@ import sys CONF = cfg.CONF -def execute_app_custom_sql(CONF, conn): +def execute_app_custom_sql(conn): """Execute custom SQL statements based on configuration. Generates custom SQL insert statements from configuration parameters @@ -31,7 +31,6 @@ def execute_app_custom_sql(CONF, conn): parameters to avoid sql injection. Parameters: - CONF (oslo_config): the global configuraiton for the app conn (sqlalchemy.db): connection object for the SQL database """ @@ -104,7 +103,11 @@ def main(argv=None): db_conn_url = db_conn_url and db_conn_url.replace("mysql+pymysql", "mysql") or '' engine = create_engine(db_conn_url, echo=False) + for exec_item in range(len(sql_queries)): + conn = engine.connect() + exec_script = conn.execute(sql_queries[exec_item]) + conn.close() + conn = engine.connect() - conn.execute('\n'.join(sql_queries)) - execute_app_custom_sql(CONF, conn) + execute_app_custom_sql(conn) conn.close()