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 <C72C33BF.10AA5%[email protected]>
Hi Federico,

I thought this problem might need you to solve. The problem is probably the
numpy.float32 . Can I fix this with a cast? Would float(...the thing that is
numpy.float32...) work?
Here's the type list for the script:
<type 'int'>
<type 'int'>
<type 'int'>
<type 'numpy.float32'>
<type 'str'>
<type 'bool'>
<type 'bool'>
<type 'bool'>
<type 'bool'>
<type 'bool'>
<type 'bool'>
<type 'bool'>
<type 'bool'>
<type 'bool'>
<type 'numpy.float32'>
<type 'numpy.float32'>
<type 'numpy.float32'>
<type 'numpy.float32'>
<type 'numpy.float32'>
<type 'str'>

Thanks,
Bill

On 11/20/09 11:36 AM, "Federico Di Gregorio" <fog-NGVKUo/i/[email protected]> wrote:

> Il giorno ven, 20/11/2009 alle 08.51 -0800, William Carithers ha scritto:
>> 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.
> 
> Hi,
> 
> "can't adapt" has nothing to do with the destination types (the types of
> the backend columns). It is a Python problem: you passed to psycopg a
> type that psycopg does not know how to render into a string suitable to
> be passed to the backend.
> 
> Can you please add something like:
> 
> for x in load:
> print type(x)
> 
> to your code and check every parameter type?
> 
> federico
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.