On Thu, Nov 29, 2007 at 06:11:11PM +0100, Bart wrote:
> I meant that I have no idea how to format the data I should be setting.
PickleCol stores pickle strings, and expects a pickle string back from
the DB. But PickleCol inherits BLOBCol, and hence with SQLite uses base64
to encode/decode pickles.
> Given that, it's trivial to give you code that doesn't work :), say...
>
> def set_data(id,data):
I rewrote your code this way:
#! /usr/bin/env python
import base64, pickle
from pysqlite2 import dbapi2 as sqlite
data = {"test1": 1, "test2": "2"}
con = sqlite.connect("test.sqdb") #my own variable. It needed a place.
cur = con.cursor()
cur.execute("CREATE TABLE test (id INTEGER PRIMARY KEY, test BLOB)")
pickledata = pickle.dumps(data,2)
cur.execute("INSERT INTO test (test) VALUES
(?)",(base64.encodestring(pickledata),))
con.commit()
cur.close()
con.close()
And get the data back in SQLObject:
from sqlobject import *
from sqlobject.sqlbuilder import *
__connection__ =
"sqlite:///home/phd/work/SQLObject/test-SQLObject/test.sqdb?debug=1"
class Test(SQLObject):
test = PickleCol()
for row in Test.select():
print row.test
It prints:
1/Select : SELECT test.id, test.test FROM test WHERE 1 = 1
1/QueryR : SELECT test.id, test.test FROM test WHERE 1 = 1
1/COMMIT : auto
{'test1': 1, 'test2': '2'}
I.e., the data is unpickled successfully.
> Well, you didn't import sqlobject, or connect to any backing database
> so I it's not exactly runnable code either, nor does it seem to apply to
> sqlite.
>
> ('course, SQLObject is slightly Weird when it comes to state and connections,
> so maybe you're doing something interesting)
Nothing interesting. The code that I've skipped is:
from sqlobject import *
from sqlobject.sqlbuilder import *
__connection__ =
"sqlite:///home/phd/work/SQLObject/test-SQLObject/test.sqdb?debug=1"
> > > You're saying 70MB
> > > non-parametric data work in sqlite right now without BLOBs?
> >
> > Works for me with BLOBCol and PickleCol, no problem.
> But sqlite has a 1MB (default) query size limit
This is the default. It seems Debian changed the default.
> Actually, I suppose the quickest short-term (but not so portable)
> fix for me is to recompile sqlite.
Certainly. In any case SQLObject cannot work around builtin SQLite
limits.
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss