Hi
I'm having some trouble with a UTF8 DB and strings not being
converted. I get the following:
'ascii' codec can't encode character u'\xe2' in position 142: ordinal
not in range(128).
See the code below. With the same engine, if I connect directly, I
have no problems but if I go via my mapped class (Source, also see
below), I get such errors.
Any ideas? Am I just being dumb here?
Cheers
Will
#ENGINE
engine = sqlalchemy.create_engine ('postgres://me:[EMAIL PROTECTED]:
5432/MAP', convert_unicode=True)
#DOESN'T WORK:
Session = sqlalchemy.orm.sessionmaker(bind=engine)
session = Session()
Source.metadata.create_all(engine)
results = session.query(Source).all()
#DOES WORK:
con = engine.connect()
results = con.execute("select abstract from base_source")
#THE SOURCE CLASS
class Source(Base):
__tablename__ = 'base_source'
id = Column(Integer, primary_key=True)
temp_author = Column(UnicodeText)
abstract = Column(UnicodeText)
year = Column(UnicodeText)
title = Column(UnicodeText)
journal = Column(UnicodeText)
ref_type = Column(UnicodeText)
url = Column(UnicodeText)
pr = Column(Boolean)
ihd= Column(Boolean)
vector = Column(Boolean)
def __init__(self, year, title, author, abstract, ref_type):
self.year = year
self.title = title
self.abstract = abstract
def __repr__(self):
return self.abstract
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---