On Sat, Oct 27, 2007 at 05:12:33AM +0200, Bart wrote:
> http://www.initd.org/tracker/pysqlite/wiki/SnippetsBlobs
> ...works for me when I hand it 500MB of data.

   1. The code

import sys
infile = open(sys.argv[1], "rb")
data = infile.read()
infile.close()

class Images(SQLObject):
   image = BLOBCol() # or PickleCol, no difference...

Images.createTable()
image = Images(image=data)

Images._connection.cache.clear()
image = Images.get(1)

outfile = open("test.dat", "wb")
outfile.write(image.image)
outfile.close()

   works for me for files up to 100M, but for bigger files OS just kills
python process due to MemoryError.
   But if I have enough memory I don't think there would be any problem
with bigger data. At least I don't see a difference between 100M and 500M.

   2. The difference between the snippet and the way SQLObject uses Binary
is that the snippet uses parameter(s) and SQLObject generates query
strings. Well, query strings work for 100M binary files...

   3. Are you sure you really want to transfer 500M in one piece to and
from a database? Wouldn't it be better to use files and store filenames in
the DB?

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
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to