[Psycopg] ProgrammingError: can't adapt (None)

Federico Di Gregorio fog at initd.org
Mon Mar 9 09:27:25 CET 2009


Il giorno ven, 06/03/2009 alle 18.32 +0100, Hartmut Goebel ha scritto:
> I'm experiencing another problem: When filling a table with data, I
> get
> an "ProgrammingError: can't adapt" when using this code segment:
> 
> ...8<---- snip ---
>    sql = 'INSERT INTO MyTable VALUES %s'
>    for row in rows:
>        ...
>        row = tuple(row)
>        curs.execute(sql, (row,) )  ## ProgrammingError here
> ...8<---- snap ---
> 
> Since tuples are handled by the handles set up in psycopg2.extensions,
> I've put in these lines to track down the problem:
> 
>      for o in row:
>          print  o
>          print psycopg2.extensions.adapt(o)
> 
> This fails with:
> 
> None
> Traceback (most recent call last):
> ...
>     print psycopg2.extensions.adapt(o)
> psycopg2.ProgrammingError: can't adapt
> 
> What is wrong here? Shouldn't all tuple values be converted into
> SQL-Syntax?

Yes but they are converted to array not to something that can be used in
an insert. Anyway, "can't adapt" is an error. What's the content of the
row?

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                fog at debian.org
INIT.D Developer                                           fog at initd.org
  Those who do not study Lisp are doomed to reimplement it. Poorly.
                                     -- from Karl M. Hegbloom .signature
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Questa ? una parte del messaggio	firmata digitalmente
URL: <http://lists.initd.org/pipermail/psycopg/attachments/20090309/910d1713/attachment.pgp>


More information about the Psycopg mailing list