Hi,

I am getting the following error, when I try to execute code to insert a 
new row into one of my tables, and I've googled for answers and tried 
everything I could find online and nothing seems to resolve the issue.

sqlalchemy.exc.ProgrammingError: (ProgrammingError) You must not use 8-bit 
bytestrings unless you use a text_factory that can interpret 8-bit 
bytestrings (like text_factory = str)

*I am using the following software:*

SQLAlchemy v0.9.8

SQLite 3.8.8.2.

*I am creating my engine as follows,*

engine = create_engine('sqlite+pysqlite:///prototype.db', module=sqlite)

#engine.raw_connection().connection.text_factory = str

#engine.connect().connection.connection.text_factory = str

session = sessionmaker(bind=engine)()

meta.Base.metadata.bind = engine

meta.Base.metadata.create_all(engine)

*The object I am trying to insert via session.add(..) has a structure 
similar to the following: (shortened for brevity)*

..

    id = Column(Integer, primary_key=True, unique=True, nullable=False)

    title = Column(String, nullable=False)     // This is the column that 
gets the Portuguese data with unicode characters -- I've tried using the 
column type Unicode

    # title = Column(Unicode, nullable=False)

    book_id = Column(Integer, nullable=False)

    code = Column(Integer, nullable=False)

...

*I've tried setting the text_factory on the connection to no avail.  I'm at 
a loss how to fix this so I can insert my data with unicode chars.*

Here is the SQL that is generated for the insert

It is highly recommended that you instead just switch your application to 
Unicode strings. u'INSERT INTO books (title, book_id, code) VALUES (?, ?, 
?)' ('Demana/Blitzer: Pr\x8e-c\x87lculo, 2e', '93810', 'removed')

I would appreciate some insight to how to fix this issue so I can insert my 
data.

Thanks,

J.D.




-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to