Skip to content

Commit

Permalink
Fixed parameter in database connection to use utf8 as the default cha…
Browse files Browse the repository at this point in the history
…rset
  • Loading branch information
guilhermechapiewski committed May 11, 2009
1 parent b5aa686 commit 1ddb975
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/simple_db_migrate/mysql.py
Expand Up @@ -22,6 +22,7 @@ def __init__(self, config=None, mysql_driver=MySQLdb):
def __mysql_connect(self, connect_using_db_name=True):
try:
conn = self.__mysql_driver.connect(host=self.__mysql_host, user=self.__mysql_user, passwd=self.__mysql_passwd)
conn.set_character_set('utf8')
if connect_using_db_name:
conn.select_db(self.__mysql_db)
return conn
Expand All @@ -36,7 +37,7 @@ def __execute(self, sql):
sql_statements = sql.split(";")
sql_statements = [s.strip() for s in sql_statements if s.strip() != ""]
for statement in sql_statements:
cursor.execute(statement)
cursor.execute(statement.encode("utf-8"))
cursor.close()
db.commit()
db.close()
Expand Down

0 comments on commit 1ddb975

Please sign in to comment.