python - TypeError: 'psycopg2._psycopg.Binary' object does not support indexing -


i need help, i'm trying insert files (.txt) postgres using psycopg2 python, sends error , don't understand...

error:

typeerror: 'psycopg2._psycopg.binary' object not support indexing 

i have:

archivo=open("coordenada.out",'rb').read()  cur.execute("insert fhi(coordenadas) values(%s)",(psycopg2.binary(archivo))) 

you missing comma:

(psycopg2.binary(archivo),) 

it expects iterable. comma make tuple. otherwise try iterate on binary


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -