title: enforce column encoding with sqlalchemy
body: <p>I am using sqlalchemy to create the schema of my database. I have no success in enforcing the use of utf-8, no matter what I tried.</p>
  
  <p>Here is a minimal python script that recreates my problem:</p>
  
  <pre><code>from sqlalchemy import create_engine, Column, Unicode
  from sqlalchemy.ext.declarative import declarative_base
  engine = create_engine('mysql+mysqldb://user:password@localhost/multidic?charset=utf8', echo=True)
  Base = declarative_base()
  class MyTableName(Base):
      __tablename__ = "mytablename"
      test_column = Column(Unicode(2),primary_key=True)
  Base.metadata.create_all(engine)
  </code></pre>
  
  <p>After running this script, when I look into the database, I see that the encoding is latin1 instead of utf-8:</p>
  
  <pre><code>mysql&gt; SHOW FULL COLUMNS FROM mytablename;
  +-------------+------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
  | Field       | Type       | Collation         | Null | Key | Default | Extra | Privileges                      | Comment |
  +-------------+------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
  | test_column | varchar(2) | latin1_swedish_ci | NO   | PRI | NULL    |       | select,insert,update,references |         |
  +-------------+------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <p>I have tried changing the type of the column created (<strong>String</strong> instead of <strong>Unicode</strong>), and tried also to add the argument <strong>encoding = "utf8"</strong> in the call to <strong>create_engine</strong>, but none of it worked.</p>
  
  <p>So, my question is:</p>
  
  <p><em>How to enforce the use of a given character encoding (utf-8 in my case) in MySQL, with sqlalchemy ?</em></p>
  
  <p>Thank you :)</p>
  
  <h2>Notes:</h2>
  
  <p>I am using sqlalchemy 0.7 and python 2.7; I can possibly upgrade one or both, but only if it is the only solution!</p>
  
  <p>I have mysql 5, and it supports utf-8:</p>
  
  <pre><code>mysql&gt; show character set where charset="utf8";
  +---------+---------------+-------------------+--------+
  | Charset | Description   | Default collation | Maxlen |
  +---------+---------------+-------------------+--------+
  | utf8    | UTF-8 Unicode | utf8_general_ci   |      3 |
  +---------+---------------+-------------------+--------+
  1 row in set (0.00 sec)
  </code></pre>