Using Microsoft Access MDB files from Ruby
|
|
Here’s a small Ruby script that I used to open and modify a Microsoft Access database file: I wrote it to hack around a limitation with Adobe Photoshop Elements 3.0 where it can’t move your entire photo library to a different location properly. I found out that they use the Microsoft Access database file format, and decided to use Ruby to modify all the paths in the database to point to the new location (I opened the file in Access first to figure out the structure and table and field names). The script doesn’t use any non-standard gems. However, it does need to run on Windows, since it relies on Microsoft’s Jet engine library (the engine that drives access to MDB files) via the “win32ole” gem that comes with Windows Ruby distributions. For reference, I did get it working with ActiveRecord via a whole other set of gems, but it’s not really worth the effort for a small project like this since one of the gems is problematic to build on Windows. Instead, I’m posting this simple version here. No ActiveRecord elegance, but no time spent on setup either. I’m posting it here in case anyone finds it useful. I think it’s also a nice demonstration of Ruby’s versatility. |