Skip to content

Commit

Permalink
Issue multiple SQL statements in separate engine.execute() calls
Browse files Browse the repository at this point in the history
Some sqlalchemy drivers (eg: mysqlconnector) don't support
engine.execute("sql stmt 1; sql stmt 2;") and require a separate
execute() call for each SQL statement.  After discussions with
sqlalchemy author, he confirmed it would be better to fix callers rather
than attempt to patch in support for multiple statements.

With this fix, keystone-manage db_sync succeeds using mysqlconnector.

Change-Id: I658a4dd479dbdcd07345c97d810c85aada3fa35b
  • Loading branch information
anguslees committed Jul 30, 2014
1 parent b6efac5 commit 0c120a4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions keystone/common/sql/migrate_repo/versions/036_havana.py
Expand Up @@ -30,11 +30,12 @@ def upgrade(migrate_engine):

if migrate_engine.name == 'mysql':
# In Folsom we explicitly converted migrate_version to UTF8.
sql_stmt = 'ALTER TABLE migrate_version CONVERT TO CHARACTER SET utf8;'
migrate_engine.execute(
'ALTER TABLE migrate_version CONVERT TO CHARACTER SET utf8')
# Set default DB charset to UTF8.
sql_stmt += ('ALTER DATABASE %s DEFAULT CHARACTER SET utf8;' %
migrate_engine.url.database)
migrate_engine.execute(sql_stmt)
migrate_engine.execute(
'ALTER DATABASE %s DEFAULT CHARACTER SET utf8' %
migrate_engine.url.database)

credential = sql.Table(
'credential', meta,
Expand Down

0 comments on commit 0c120a4

Please sign in to comment.