[Tutor] string pickling and sqlite blob'ing

vince spicer vinces1979 at gmail.com
Thu Jun 25 16:38:41 CEST 2009


Dinesh

In theory you can store in either type(i have done it), however you should
store in the binary column, blob

Vince



On Wed, Jun 24, 2009 at 2:42 PM, Dinesh B Vadhia
<dineshbvadhia at hotmail.com>wrote:

>  Hi Vince
>
> That's terrific!  Once a string is compressed with gzip.zlib does it make a
> difference whether it is stored it in a TEXT or BLOB column?
>
> Dinesh
>
>
>
> *From:* vince spicer <vinces1979 at gmail.com>
> *Sent:* Wednesday, June 24, 2009 10:49 AM
> *To:* Dinesh B Vadhia <dineshbvadhia at hotmail.com>
> *Cc:* tutor at python.org
> *Subject:* Re: [Tutor] string pickling and sqlite blob'ing
>
> Pickle is more for storing complex objects (arrays, dict, etc). pickling a
> string makes it bigger.
>
> I have stored large text chunks in text and/or blob columns compressed with
> gzip.zlib.compress and extracted with gzip.zlib.decompress
>
> Comparison:
>
> import cPickle as Pickle
> import gzip
>
> x = "asdfasdfasdfasdfasdfasdfasdfasdfasdf"
>
> print len(x)
> >> 36
>
> print len(Pickle.dumps(x))
> >> 44
>
> print len(gzip.zlib.compress(x))
> >> 14
>
>
> Vince
>
> On Wed, Jun 24, 2009 at 11:17 AM, Dinesh B Vadhia <
> dineshbvadhia at hotmail.com> wrote:
> I want to pickle (very long) strings and save them in a sqlite db.  The
> plan is to use pickle dumps() to turn a string into a pickle object and
> store it in sqlite.  After reading the string back from the sqlite db, use
> pickle loads() to turn back into original string.
>
> - Is this a good approach for storing very long strings?
>
> - Are the pickle'd strings stored in the sqlite db as a STRING or BLOB?
>
> Cheers.
>
> Dinesh
>
>
>
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090625/0c240da5/attachment.htm>


More information about the Tutor mailing list