Kin
2014-02-21 19:42:52 UTC
Hello.
i am not being able to write those traditional chinese characters to my
mysql database.
http://docs.sqlalchemy.org/en/rel_0_9/dialects/mysql.html
I should have been able to write unicode characters to my mysql database,
and be able to read them as written.
Unfotunately, while writing them as: 'è»ä»¶éçŒäººå¡'
I obtained their utf8 encoded version which is: 'Ú»ŞÀ»¶éââ¹Ã§â¢ÂŒÃ€ÂºÂºÃ¥â¡'
i did attempt writing them manually to sqlalchemy and the whole process
work.
But I do not understand why this not working with sqlalchemy while I
specifically requested it to be written to the database as utf8 using "
*charset=utf8*" , then read from it as unicode using "*use_unicode=1'*"
the mysql version is: 5.5.35-0ubuntu0.12.04.2-log
the sqlalchemy version is:0.8.3
Please let me know what you think.
Here is the code i used to fill the database, table and columns:
*from sqlalchemy import create_engine*
*from sqlalchemy import Column, String, BigInteger*
*from sqlalchemy.ext.declarative import declarative_base*
*from sqlalchemy import types*
*from sqlalchemy.dialects.mysql import VARCHAR*
*engine =
create_engine('mysql+mysqldb://root:foo@<dbIpaddress>/testdb3?charset=utf8&use_unicode=1')*
*Base = declarative_base()*
*class Writers3(Base):*
* __tablename__ = "writers3"*
* __table_args__ = {'mysql_engine': 'InnoDB'}*
* id = Column(BigInteger(20), primary_key=True)*
* account = Column(VARCHAR(length=25, unicode = True))*
* def __init__(self, account):*
* self.account = account*
*Base.metadata.create_all(engine)*
And here is the code I used to fill the table with values:
*from clean_table_def import Writers3*
*from sqlalchemy.ext.declarative import declarative_base*
*from sqlalchemy import create_engine*
*from sqlalchemy.orm import sessionmaker, scoped_session*
*db_url = 'mysql://root:***@dbIpAddress/testdb3'*
*engine1 = create_engine(db_url, pool_recycle=2*60*60)*
*Session = sessionmaker(bind=engine1)*
*session = Session()*
*object1 = Writers3( 'è»ä»¶éçŒäººå¡')*
*session.add(object1)*
*session.commit()*
*session.close()*
i am not being able to write those traditional chinese characters to my
mysql database.
http://docs.sqlalchemy.org/en/rel_0_9/dialects/mysql.html
I should have been able to write unicode characters to my mysql database,
and be able to read them as written.
Unfotunately, while writing them as: 'è»ä»¶éçŒäººå¡'
I obtained their utf8 encoded version which is: 'Ú»ŞÀ»¶éââ¹Ã§â¢ÂŒÃ€ÂºÂºÃ¥â¡'
i did attempt writing them manually to sqlalchemy and the whole process
work.
But I do not understand why this not working with sqlalchemy while I
specifically requested it to be written to the database as utf8 using "
*charset=utf8*" , then read from it as unicode using "*use_unicode=1'*"
the mysql version is: 5.5.35-0ubuntu0.12.04.2-log
the sqlalchemy version is:0.8.3
Please let me know what you think.
Here is the code i used to fill the database, table and columns:
*from sqlalchemy import create_engine*
*from sqlalchemy import Column, String, BigInteger*
*from sqlalchemy.ext.declarative import declarative_base*
*from sqlalchemy import types*
*from sqlalchemy.dialects.mysql import VARCHAR*
*engine =
create_engine('mysql+mysqldb://root:foo@<dbIpaddress>/testdb3?charset=utf8&use_unicode=1')*
*Base = declarative_base()*
*class Writers3(Base):*
* __tablename__ = "writers3"*
* __table_args__ = {'mysql_engine': 'InnoDB'}*
* id = Column(BigInteger(20), primary_key=True)*
* account = Column(VARCHAR(length=25, unicode = True))*
* def __init__(self, account):*
* self.account = account*
*Base.metadata.create_all(engine)*
And here is the code I used to fill the table with values:
*from clean_table_def import Writers3*
*from sqlalchemy.ext.declarative import declarative_base*
*from sqlalchemy import create_engine*
*from sqlalchemy.orm import sessionmaker, scoped_session*
*db_url = 'mysql://root:***@dbIpAddress/testdb3'*
*engine1 = create_engine(db_url, pool_recycle=2*60*60)*
*Session = sessionmaker(bind=engine1)*
*session = Session()*
*object1 = Writers3( 'è»ä»¶éçŒäººå¡')*
*session.add(object1)*
*session.commit()*
*session.close()*
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.