Typeerror: Argument 1 Must Be A String Or Unicode Object
Using this query: 04/25/2017 00:42:28.180 INFO (u'UPDATE posts SET translated_text='Unroll.me CEO dice que es "desgarrador" que los usuarios se molesten Unroll.me
Solution 1:
That log is showing a tuple of unicode strings, rather than a unicode string. Try logging the type of query
before you execute it to check.
The preferred way to log parameterised query is:
query = u"UPDATE posts SET translated_text='%s', detected_language='%s' WHERE post_id=%s;"vars = translation, detected_language['language'], str(post_id) # tuple
cur.execute(query, vars)
You may also wish to explicitly convert the strings of vars
into unicode rather than relying on this to be done implicitly. eg.
vars = translation, detected_language['language'].decode("utf8"), str(post_id).decode("utf8")
Post a Comment for "Typeerror: Argument 1 Must Be A String Or Unicode Object"