Hi, 2010/6/15 Roger Binns <rog...@rogerbinns.com>
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 06/15/2010 01:46 PM, Fabio Spadaro wrote: > > I am developing an interface to Python 's SQLite and would it be > > you can store files in the sqlite database. To do this > > obviously need to create a blob field but how to store image files? > > If you are using Python 2 then use the buffer type. If using Python 3 then > use bytes. > > Py2: > > cursor.execute("insert into foo(image) values(?)", > (buffer(open(".../foo.jpg", "rb").read()), )) > > Py3: > > cursor.execute("insert into foo(image) values(?)", > (open(".../foo.jpg", "rb").read(), )) > > > If you use APSW then you can also use the incremental blob API: > > http://apsw.googlecode.com/svn/publish/blob.html > > Roger > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.10 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iEYEARECAAYFAkwX7yAACgkQmOOfHg372QSIkQCfej/1Zw7htLxZtVFGsIsxb91m > YnkAniPp7aScNJITD3xYOmH4MC9e4Asx > =M6pK > -----END PGP SIGNATURE----- > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > Another question. If I wanted to convert the buffer to a file how should I do? -- Fabio Spadaro www.fabiospadaro.com _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users