how to store binary file data to a database blob
Ivan Voras
iv at an.voras.fer.hr
Thu May 27 11:39:33 EDT 2004
Benjamin Niemann wrote:
> using the % operator. This works at least for arbitrary strings (and
> that's the way to handle strings, if you don't like SQL injections ;)
> But I never tried this with blobs - perhaps they need some special
> treatment (thinking e.g. of laaarge files)...
It is generally NOT a good idea to write large binary strings to a (sql
relational) database, even if it has blobs. A much more robust (and faster)
solution is to save general data about the blob in the database (its size,
name, whatever, etc.) and the actual data in a separate file in the
filesystem (or maybe in a "db" database (BDB, GDBM...), if you really like
them).
YMMV, mostly depending on the size of blobs. :)
More information about the Python-list
mailing list