Entries from August 2006 ↓

Tech Tip of the Day: MySQL binary export

This is a short and sweet tech tip. If you have binary data, such as images or zip files, stored in a mysql database, this technique will export those blobs (binary large objects) back to the file system.

Case:

Bugzilla attachments exist in mysql that now must be exported to another bug tracking system.

Approach:
Run this query

select thedata from attachments where bug_id='224' and mimetype not like 'text/plain' and mimetype not like 'text/hmtl' into dumpfile '/data/bug-224-attachment.zip';

for each bug that contains a binary attachment. You can extend this approach by writing a script that queries for all bugs with attachments, then acts only on those those that are binary attachments. Since you may wish to include the file type attachment in the dumpfile name, consider adding an additional loop that checks for the mimetypes that correspond to each of the various binary formats (jpg, zip, etc.). Pass both the bug_id and the mimetype into the filename that you create in the dumpfile.

Tags: , ,

Tech Tip of the Day: mod_rewrite & AllowOverride

Recently, an upgrade of the OS on the commavee server resulted in the blog post URLs failure to resolve. Earlier blog posts, with the date-and-post title formatted URL, were now unresolvable. This meant that every post in the search engines (and even the site itself) resulted in a 404 Not found error. It took a bit of investigation, but the solution was straight-forward.

Continue reading →