AttributeError: 'tuple' object has no attribute 'encode'

kyosohma at kyosohma at
Thu Apr 5 17:41:37 CEST 2007

On Apr 5, 10:31 am, "erikcw" <erikwickst... at> wrote:
> Hi,
> I'm trying to build a SQL string
> sql = """INSERT INTO ag ('cid', 'ag', 'test') VALUES(%i, %s, %d)""",
> (cid, ag,[parent][child]['results']['test'])
> It raises this error: AttributeError: 'tuple' object has no attribute
> 'encode'
> Some of the variables are unicode (test and ag) - is that what is
> causing this error?  What do I need to do to make it work?
> Thanks!
> Erik

It sounds like you're not calling the "encode" method correctly. But
it's hard to say when you didn't include that bit of code. You may
need to check your database's docs to make sure it accepts unicode
strings and if so, what types (utf-8, 16, 32).

See this post for a similar problem:

and this link details tuple usage:


More information about the Python-list mailing list