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]c0aa317940

Change-Id: If139f0941562b7a792d813b5e23a47eb92487304
Story: 2001420
This commit is contained in:
Trevor McCasland 2017-12-21 14:15:09 -06:00
parent 989b0a3563
commit 37fc3f5f38

View File

@ -43,7 +43,10 @@ def upgrade():
migration_context = context.get_context() migration_context = context.get_context()
if migration_context.dialect.name == 'mysql': if migration_context.dialect.name == 'mysql':
with open(sql_path, 'r') as sql_file: 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: else:
op.add_column('test_runs', sa.Column('start_time_microsecond', op.add_column('test_runs', sa.Column('start_time_microsecond',
sa.Integer(), default=0)) sa.Integer(), default=0))