How can i store pickle dumps data ?

A

Abandoned

Hi..
I have some dictionary as {2:3, 4:6, 5:7.........}
I want to pickle to these dictionary and save to database but i
couldn't..

My code for adding..
a=eval(dict)
a=pickle.dumps(a, -1)
cursor2.execute("INSERT INTO cache VALUES ('%s', %s)", (x[0],a))
conn2.commit()

i try in UTF-8 postresql database (data type BYTEA) and it gives me
this error:
psycopg2.ProgrammingError: invalid byte sequence for encoding "UTF8":
0x80
HINT: This error can also happen if the byte sequence does not match
the encoding expected by the server, which is controlled by
"client_encoding".

i try in LATIN5 postgresql database (data type BYTEA) and it add first
10 element and than gives me this error:
cursor2.execute("INSERT INTO cache VALUES ('%s', %s)", (x[0],a))
psycopg2.ProgrammingError: invalid input syntax for type bytea

i try in LATIN5 (data type TEXT) and it add all element but when i
want to load it give me this error:
pickle.loads(SELECTED_DATA);
EOFError


Now how can i store the pickle data ?
Which encoding and which data type ?
Please help me i'm sorry my bad english.
King Regards..
 
D

Diez B. Roggisch

Abandoned said:
Hi..
I have some dictionary as {2:3, 4:6, 5:7.........}
I want to pickle to these dictionary and save to database but i
couldn't..

My code for adding..
a=eval(dict)
a=pickle.dumps(a, -1)
cursor2.execute("INSERT INTO cache VALUES ('%s', %s)", (x[0],a))
conn2.commit()

i try in UTF-8 postresql database (data type BYTEA) and it gives me
this error:
psycopg2.ProgrammingError: invalid byte sequence for encoding "UTF8":
0x80
HINT: This error can also happen if the byte sequence does not match
the encoding expected by the server, which is controlled by
"client_encoding".

i try in LATIN5 postgresql database (data type BYTEA) and it add first


http://mail.python.org/pipermail/python-list/2004-September/280867.html


Diez
 
A

Abandoned

Abandoned schrieb:




Hi..
I have some dictionary as {2:3, 4:6, 5:7.........}
I want to pickle to these dictionary and save to database but i
couldn't..
My code for adding..
a=eval(dict)
a=pickle.dumps(a, -1)
cursor2.execute("INSERT INTO cache VALUES ('%s', %s)", (x[0],a))
conn2.commit()
i try in UTF-8 postresql database (data type BYTEA) and it gives me
this error:
i try in LATIN5 postgresql database (data type BYTEA) and it add first

http://mail.python.org/pipermail/python-list/2004-September/280867.html

Diez- Hide quoted text -

- Show quoted text -

Yes this is wonderfull.
I am very happy thank you very much Diez.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top