mfenniak / pg8000

A Pure-Python PostgreSQL Driver
http://pythonhosted.org/pg8000/
Other
222 stars 55 forks source link

Losing lowercase `u` with string interpolation? #158

Closed micah-williamson closed 5 years ago

micah-williamson commented 6 years ago

I've found a strange issue where it appears lowercase u characters are getting removed with %s string interpolation is used.

cursor.execute("""
            INSERT INTO public.foo
            (names)
            VALUES
            (%s)
        """, (['HustonU']))

Would insert

{HstonU}

Has anyone encountered this before?

tlocke commented 5 years ago

Hi @iamchairs I think Python needs a comma for a tuple with one item, so perhaps the code should look like:

cursor.execute("""
            INSERT INTO public.foo
            (names)
            VALUES
            (%s)
        """, (['HustonU'],))