On 5/9/06, Rune Hansen <[EMAIL PROTECTED]> wrote:
>
> Using MySQLdb-1.2.1p2 I get a 'ascii' codec can't decode byte 0x8b in
> position 50: ordinal not in range(128) when using SQLObject to insert data
> into the database:
> mldata(uid=uid,data=MySQLdb.Binary(gzipped.getvalue()))
>
> This does work:
> cur.execute("INSERT INTO mldata (uid,data) VALUES
> (%s,%s)",(uid,MySQLdb.Binary(gzipped.getvalue())))

This is a side effect of SQLObject not using prepared statements. You
might create your own column object that wraps the automatically does
the MySQLdb.Binary part and escapes anything that doesn't fit into the
'ascii' range (just envision what the query would need to look like if
the insert was being run as a big string).

You could also directly run the query in the prepared statement form
that works. A solution that is more difficult but pays other dividends
would be to switch to SQLAlchemy.

> Also, If I use SQLObject and run into a IntegrityError my TG app locks up
> hard. Is this expected behavior? What do I do to continue the request?

It certainly *shouldn't* do that, but that is a case that I haven't
run into with TG.

Kevin

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to