Sign in to follow this  
AcidZombie24

sql blobs

Recommended Posts

so i am thinking of using sql lite. when i insert a binary file (i'll probably only do this once for each entry) i need to convert it to ascii to avoid null? i would need to convert this to 2 hex letters per byte? Doesnt this take make terrible overhead since more then 99% of my DB will be blobs? should i instead generate a filename and stick it in a text field instead creating the blob as a file? i decided to use a db bc the non blob fields will be read a lot and may be extended. the blob isnt accessed as much and will not be extend.

Share this post


Link to post
Share on other sites
there will be tags attached to the blobs such as date and comments. These will grow, sometimes shrink and i'll use some of that date for searching. (mainly timestamps). There will also be groups which also have comments and dates which will extend as i add more items to the group.

I do have to convert the bin data to ascii data? (or at least remove null and potential escape sequence?) is there a way i can feed a pointer and length in bytes?

I havent used sql much.

Share this post


Link to post
Share on other sites
SQLite 3 is binary-safe for both strings and blobs. Just pass the length as a parameter to sqlite3_bind_blob, and you shouldn't have any problems. There's no need to roll your own ASCII encoding or anything like that.

Reference: http://sqlite.org/c3ref/bind_blob.html

Share this post


Link to post
Share on other sites
Any SQL-implementation should have no problem with 0-bytes in BLOBs. BLOB is an acronym for Binary Large OBject for a reason.

I do remember using BLOBs in a database once and have MySQL have quite some trouble with it, and I had to use the link-approach you already mentioned. But that's way way back so may have been fixed. (Although still apps like MediaWiki and Gallery do not store their binaries in the DB, mmmm...).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this