[EMAIL PROTECTED] wrote:
>> # Ensure that we're running Python 3 or later.
>> import sys
>> assert int(sys.version.split()[0].split('.')[0]) >= 3
>> # If there's a better way to chek, please tell.
[...]
Why split at all? Just use sys.version_info:
>>> import sys
>>> a
>> # Ensure that we're running Python 3 or later.
>> import sys
>> assert int(sys.version.split()[0].split('.')[0]) >= 3
>> # If there's a better way to chek, please tell.
>>
MRAB> [snip]
MRAB> Why split on whitespace and then '.'?
MRAB> assert int(sys.version.spl
Bryan Olson wrote:
Gerhard Häring wrote:
Be sure to save it as BLOB, not TEXT.
Suppose you have serialized your object as Python bytestring.
serialized = ...
... .execute("insert into mytable(mycolumn) values (?)",
(sqlite3.Binary(serialized),))
This way you will get a BLOB in the form
Gerhard Häring wrote:
Be sure to save it as BLOB, not TEXT.
Suppose you have serialized your object as Python bytestring.
serialized = ...
... .execute("insert into mytable(mycolumn) values (?)",
(sqlite3.Binary(serialized),))
This way you will get a BLOB in the form of a Python buffer
[EMAIL PROTECTED] a écrit :
Bruno> If you serialize a dict, you'll obviously get a dict back. Note
Bruno> that the point of json is *not* to replace pickle. json is a
Bruno> *data* serialization format meant to represent "basic" types
Bruno> (dicts, lists, strings and numbers) in
Bruno> If you serialize a dict, you'll obviously get a dict back. Note
Bruno> that the point of json is *not* to replace pickle. json is a
Bruno> *data* serialization format meant to represent "basic" types
Bruno> (dicts, lists, strings and numbers) in human readable and
Bruno>
[EMAIL PROTECTED] a écrit :
Bruno> Most of the time, you want to serialize the instance's __dict__.
Does it recreate an instance at the other end or just a dict?
If you serialize a dict, you'll obviously get a dict back. Note that the
point of json is *not* to replace pickle. json is a *d
On Dec 3, 10:21 pm, Gerhard Häring <[EMAIL PROTECTED]> wrote:
> azrael wrote:
> > It logical that it would be more efficient and logical to use a object
> > oriented database, but in this case I ask because of the portable
> > nature of sqlite.
>
> > so, if I get it right, this should be possible [
azrael wrote:
It logical that it would be more efficient and logical to use a object
oriented database, but in this case I ask because of the portable
nature of sqlite.
so, if I get it right, this should be possible [...]
Did you try it? Did it work? If so,it was pure luck. Attached is a
scri
Bruno> Most of the time, you want to serialize the instance's __dict__.
Does it recreate an instance at the other end or just a dict?
Skip
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] a écrit :
Bruno> Or if you want something more portable, serialize the object to
Bruno> json. At least you'll have a chance to deserialize it with some
Bruno> other language.
Assuming json can serialize more-or-less arbitrary Python objects.
I assume the OP knows
It logical that it would be more efficient and logical to use a object
oriented database, but in this case I ask because of the portable
nature of sqlite.
so, if I get it right, this should be possible
>>> class a:
>>> def __init__(self, a, b):
>>> self.c = a+b
>>> self.d = a*b
>>>
>>>
[EMAIL PROTECTED] wrote:
> azrael> is it possible to save a python object into a sqlite database as
> azrael> an atribute of type BLOB
>
> Sure. Just pickle the object and save the resulting string.
Be sure to save it as BLOB, not TEXT.
Suppose you have serialized your object as Python
Bruno> Or if you want something more portable, serialize the object to
Bruno> json. At least you'll have a chance to deserialize it with some
Bruno> other language.
Assuming json can serialize more-or-less arbitrary Python objects. Can
it serialize class instances?
Skip
--
http://ma
[EMAIL PROTECTED] a écrit :
azrael> is it possible to save a python object into a sqlite database as
azrael> an atribute of type BLOB
Sure. Just pickle the object and save the resulting string.
Or if you want something more portable, serialize the object to json. At
least you'll have
azrael> is it possible to save a python object into a sqlite database as
azrael> an atribute of type BLOB
Sure. Just pickle the object and save the resulting string.
--
Skip Montanaro - [EMAIL PROTECTED] - http://smontanaro.dyndns.org/
--
http://mail.python.org/mailman/listinfo/python-
is it possible to save a python object into a sqlite database as an
atribute of type BLOB
--
http://mail.python.org/mailman/listinfo/python-list
17 matches
Mail list logo