Strings and % sign fails - Help Please

2006-03-23 Thread siasookhteh
I also posted this in Django Users group, but figured it probably has
more relevance for python group.

It seems like a freak problem to me.  I spent a long hour to track the
problem down and here it is:

The following statement fails because it has the '%' sign in it.
cursor.execute("select '%'")

The error is: IndexError: list index out of range

How do I address this problem?

Please note that the following work just fine:
cursor.execute("select 'x'")

and the following also fails with the same error:
cursor.execute("""select '%'""")
cursor.execute("select '\%'")

astr = "select '\%'"
cursor.execute(astr)

I greatly appreciate all helps,
Regards,
Sia

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Strings and % sign fails - Help Please

2006-03-23 Thread siasookhteh
heh.. It works except I am using psycopg.Binary(somebinarystructure),
and I am not really doing it by hand to just add the extra %, and
psycopg.Binary doesn't do it. I'd imagine it's a bug with psycopg
package.  Any quick way to project a string from freak '%' problems?

Thanks,
Sia


Jorge Godoy wrote:
> [EMAIL PROTECTED] writes:
>
> > The following statement fails because it has the '%' sign in it.
> > cursor.execute("select '%'")
> >
> > The error is: IndexError: list index out of range
> >
> > How do I address this problem?
>
> Use "%%".
>
>
> --
> Jorge Godoy  <[EMAIL PROTECTED]>
>
> "Quidquid latine dictum sit, altum sonatur."
> - Qualquer coisa dita em latim soa profundo.
> - Anything said in Latin sounds smart.

-- 
http://mail.python.org/mailman/listinfo/python-list