473,378 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How can i store pickle dumps data ?

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..

Oct 20 '07 #1
2 2342
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:
>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/pyt...er/280867.html
Diez
Oct 20 '07 #2
On Oct 20, 5:32 pm, "Diez B. Roggisch" <de...@nospam.web.dewrote:
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:
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/pyt...er/280867.html

Diez- Hide quoted text -

- Show quoted text -
Yes this is wonderfull.
I am very happy thank you very much Diez.

Oct 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tomasz Lisowski | last post by:
The documentation says, that the output from pickle.dumps() consists of "printable ASCII" characters. Does it mean the range from ASCII 32 to 127? Or the expected character range is different? ...
3
by: Michael Hohn | last post by:
Hi, under python 2.2, the pickle/unpickle sequence incorrectly restores a larger data structure I have. Under Python 2.3, these structures now give an explicit exception from...
2
by: Boris Borcic | last post by:
Assuming that the items of my_stream share no content (they are dumps of db cursor fetches), is there a simple way to do the equivalent of def pickles(my_stream) : from cPickle import...
3
by: Iljya | last post by:
Hello, I need to pickle the type numpy.float32 but encounter an error when I try to do so. I am able to pickle the array itself, it is specifically the type that I cannot pickle. I am using:...
5
by: Chris | last post by:
Why can pickle serialize references to functions, but not methods? Pickling a function serializes the function name, but pickling a staticmethod, classmethod, or instancemethod generates an...
8
by: Victor Kryukov | last post by:
Hello list, I've found the following strange behavior of cPickle. Do you think it's a bug, or is it by design? Best regards, Victor. from pickle import dumps from cPickle import dumps as...
2
by: Michele Simionato | last post by:
Can somebody explain what's happening with the following script? $ echo example.py import pickle class Example(object): def __init__(self, obj, registry): self._obj = obj self._registry =...
2
by: Nagu | last post by:
I am trying to save a dictionary of size 65000X50 to a local file and I get the memory error problem. How do I go about resolving this? Is there way to partition the pickle object and combine...
0
by: Nagu | last post by:
I am trying to save a dictionary of size 65000X50 to a local file and I get the memory error problem. How do I go about resolving this? Is there way to partition the pickle object and combine...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.