* Magic files for reading/writing to a database
@ 2007-01-29 1:45 Greg Detre
0 siblings, 0 replies; only message in thread
From: Greg Detre @ 2007-01-29 1:45 UTC (permalink / raw)
To: help-gnu-emacs
Dear all,
I'm trying to build a magic files interface that will allow
me to read/write records from a sql database as if they're
files. I can see many applications of this - for instance,
one could edit blog or wiki entries in a database directly,
as though they were flat files.
I've been able to read the information from the database
using a combination of Pymacs (to interface my elisp code
with python code) and Sqlalchemy, an awesome high-level
python library that interfaces with sqlite, mysql, postgres
and other database engines in a nice object-oriented way. So
I can call some function like (magiql-get-contents pkey) and
have it return the text I want, and then save any
modifications back to the database in a very natural way. So
far so good.
The next magic files step is to handle the (magiql-get-contents)
and (magiql-write-contents) functions with a
file-name-handler function, along with any other auxiliary
functions I might need. I want to be able to deal with a
sqlite file like this:
magiql:~/mydatabase.db:1
where 'magiql' is the name of the package i'm writing,
~/mydatabase.db is a sqlite file, and 1 is the primary key
of the record I'm after. In the future, I hope to generalize
this so that one could use other database engines, or
incorporate SQL code in the filename, but let's keep things
simple.
I've spent a fair while reading and re-reading the brief
section on magic files in the GNU Emacs manual:
http://www.gnu.org/software/emacs/elisp/html_node/Magic-File-
Names.html
and the TRAMP source code, as well as a few of the comments
on gnu.emacs.help, but I haven't been able to find a simple,
documented example that uses magic files. The TRAMP code is
beautifully commented and laid out, but I don't think anyone
would deny that it's complex. Can anyone recommend some
documentation or example code to help me figure out where my
current code is going wrong?
Many thanks in advance,
Yours,
Greg
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-01-29 1:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-29 1:45 Magic files for reading/writing to a database Greg Detre
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).