Fixed a problem with db_setup.py dropping table creation statements

Change-Id: I14a0d7ee26ab5ca69a2860bbf2b9006d1b2aab33
This commit is contained in:
jmq 2019-05-22 10:17:35 -05:00
parent cf78b0eaf5
commit 2b6c2d8e06

@ -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()