From 37fc3f5f3862b00e183676612da9867aeaaad6f9 Mon Sep 17 00:00:00 2001 From: Trevor McCasland Date: Thu, 21 Dec 2017 14:15:09 -0600 Subject: [PATCH] Fix mysql db api By default the multiline option for the db api was included in PyMySql<0.8 but now that it is removed[1] we need to pass in the multi=True argument to the cursor to maintain the same execution behavior. Unfortunately, I wasn't sure on how to do that so I modified the op.execute method to run the sql commands one line at a time instead. It seems to work for the test cases. [1]https://github.com/PyMySQL/PyMySQL/commit/c0aa3179406571592d3beb9d5a35badc4047cb79 Change-Id: If139f0941562b7a792d813b5e23a47eb92487304 Story: 2001420 --- .../1679b5bc102c_add_subsecond_columns_to_test_runs_table.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/subunit2sql/migrations/versions/1679b5bc102c_add_subsecond_columns_to_test_runs_table.py b/subunit2sql/migrations/versions/1679b5bc102c_add_subsecond_columns_to_test_runs_table.py index fe1a969..e26e05b 100644 --- a/subunit2sql/migrations/versions/1679b5bc102c_add_subsecond_columns_to_test_runs_table.py +++ b/subunit2sql/migrations/versions/1679b5bc102c_add_subsecond_columns_to_test_runs_table.py @@ -43,7 +43,10 @@ def upgrade(): migration_context = context.get_context() if migration_context.dialect.name == 'mysql': with open(sql_path, 'r') as sql_file: - op.execute(sql_file.read()) + for line in sql_file.read().splitlines(): + # don't execute empty or commented lines + if line and not line.startswith('--'): + op.execute(line) else: op.add_column('test_runs', sa.Column('start_time_microsecond', sa.Integer(), default=0))