Re: "ProgrammingError: can't adapt" when passing arguments to cursor.execute
Eric Chamberlain <Eric.Chamberlain-/Guk6kGqSwklJZD/[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
I had this same exact issue when I was using the suds SOAP library. It was trying to cast a suds.sax.text.Text and couldn't adapt. The trick was to put the variable in str(). In your case you may need to cast the numpy.float32 into a float with float(). Hope this helps. Eric Chamberlain On Nov 20, 2009, at 11:53 AM, William Carithers wrote: > 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 > > > _______________________________________________ > Psycopg mailing list > Psycopg-IAPFreCvJWPBWskQ1e/[email protected] > http://lists.initd.org/mailman/listinfo/psycopg Confidentiality Notice: This e-mail may contain proprietary information some of which may be legally privileged. It is for the intended recipient(s) only. If you believe that it has been sent to you in error, please notify the sender by reply e-mail and delete the message. Any disclosure, copying, distribution or use of this information by someone other than the intended recipient(s) is prohibited and may be unlawful.