From time to time I wanted to access data in my database as a filesystem. Wouldn't it be nice to just say

vi /db/invoice/2004/01/03/paid.txt
To edit one field instead of writing SQL? But, after installation of WebGUI I realised that I have to do something. All templates are stored in database, and edit box is so small (and without support for vi key bindings :-).

At about same time, I stumbeled upon Fuse project with it's perl bindings. I had idea, and it was simple: write a bridge between database and filesystem.

That bridge is called Fuse::DBI. I just announced it on WebGUI site, but now I have doubt: is this module right material for CPAN?

I should stress that this module isn't general purpose database to filesystem bridge. It allows user to export one part of database (usually one or more tables) as a filesystem (much like /proc filesystem on Linux).

This is done with three SQL queries: one to return filenames, lenghts and write permission, another to return content and third one to update content. It also has optional code hook to invalidate cache (on disk cache created from database for example) if needed.

Advantage of this approach is ability to use different filesystem tools to access data from database without writing specific support for each of them (like editors, ftp servers and so on).

On one hand, we have binding of Lufs (other project with similar goal) on CPAN allready. On other hand, Lufs module is binding for lufs, not module which uses another perl module which isn't on CPAN.

What is best practice for situations like this? Do you like idea to mount database as filesystems?
Please be gantle. I don't think that code is best example how to write perl module, partly because of functional interface in Fuse module itself. But, result is so interesting that I wanted to share it.

Updated 2004-10-09: added explanation about usage of this module.

2share!2flame...

In reply to RFC: Fuse::DBI - mount database as filesystem by dpavlin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.