Re: "ProgrammingError: can't adapt" when passing arguments to cursor.execute
William Carithers <wccarithers-/[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <C72C0904.10A77%[email protected]> |
Hi Adrian, Thanks. I was worried about exactly that problem such as trying to load a boolean into a column expecting a real. So I literally cut and pasted the values from the "load" list in the script editor into the "load" list in the interactive session. It worked in one case and not in the other. I'm not sure why there is a roundoff difference but as long as values are consistent about data types, I would think that it would be OK but at this point my confidence level is pretty low. Cheers, Bill On 11/20/09 8:27 AM, "Adrian Klaver" <[email protected]> wrote: > On Friday 20 November 2009 7:55:16 am William Carithers wrote: >> Hi Tim, >> >> Thanks for the suggestions. I don't think that Python versions are the >> problem because when I first ran the script, it couldn't import psycopg2. >> Then I remembered that I had upgraded to Mac OS 10.6 (aka Snow Leopard) >> which ships with Python 2.6 since I last worked with psycopg2. Sure enough, >> my old psycopg was in site-packages for Python 2.5. So I installed the >> latest psycopg2 on Python2.6 and the script was happy to import. For the >> interactive session, the Python version comes up automatically and it was >> 2.6. >> >> Unfortunately changing load from a list to a tuple didn't solve the >> problem: Traceback (most recent call last): >> File "./loadDB.py", line 117, in <module> >> sys.exit(main()) >> File "./loadDB.py", line 87, in main >> curs.execute(query, tuple(load)) >> psycopg2.ProgrammingError: can't adapt >> >> Same thing with changing load = (...) instead of load[...] >> >> Thanks again, >> Bill >> > > The 'can't adapt' part would seem to me to indicate a data type problem that > the > psycopg adapters can not handle. Hence my previous post about investigating > why > the float values where different in the two examples you showed. >