title: Alembic migration script for a MySQL View using DATE_FORMAT
body: <p>We are attempting to generate a SQL Migration script using Alembic (offline mode).  Part of the view in the migration uses the MySQL function DATE_FORMAT, as in the example below.  When the migration scripts are created, the percent characters are being doubled-up in the generated SQL.  </p>
  
  <p>We've been manually modifying the generated scripts to set it back to a single % character instead, but would like to get out of that practice and have our upgrades / downgrades generate SQL that can be piped into the db without manually modification.</p>
  
  <p>From what I have been able to determine, running the Alembic migration in online mode with the no_parameters = True set in the execution_options allows, "<em>...percent signs straight through without escaping, thus providing cross-compatible operation with DBAPI execution and static script generation.</em>" </p>
  
  <p>(<em>see:</em> <a href="https://alembic.readthedocs.org/en/latest/changelog.html#change-1dff9e522d76403d9af885164fd284e9" rel="nofollow">https://alembic.readthedocs.org/en/latest/changelog.html#change-1dff9e522d76403d9af885164fd284e9</a> )</p>
  
  <p>Since the execution_options are set as a property of the Connection and no connection is present when running in offline mode, this does not seem to be an option for us.</p>
  
  <p>Any help or advice would be most appreciated!</p>
  
  <p>=======================</p>
  
  <h1>Alembic migration file:</h1>
  
  <pre><code>def upgrade():
      my_view_sql = """
          CREATE VIEW my_view
          AS        
          SELECT DATE_FORMAT(m.my_date, '%m/%d/%Y') AS 'my_date'
          FROM    some_table as m
      """
      op.execute(my_view_sql)
  </code></pre>
  
  <p>======================</p>
  
  <h1>Generated SQL:</h1>
  
  <pre><code>-- Running upgrade old_version -&gt; new_version
  
  CREATE VIEW my_view
          AS
          SELECT DATE_FORMAT(m.my_date, '%%m/%%d/%%Y') AS 'my_date'
          FROM    some_table as m;
  
  UPDATE alembic_version SET version_num='new_version';
  </code></pre>