3

I want to manage simple personal databases, like mp3 collections.

I am not aware of any updated lisp object database project working in Emacs (correct me if I am wrong).

So I would turn to Sqlite, because it seems the only viable serverless database (right?). Have you experience with some library to create or query tables?

I am not particularly interested to Emacs SQL modes, but to libraries sending commands to DBs.

antonio
  • 1,762
  • 12
  • 24
  • 1
    See http://nullprogram.com/blog/2014/02/06/ – abo-abo Feb 24 '15 at 19:20
  • Emacs can be extended with Scheme, Common Lisp and Python (maybe more?). This means that you can use any of those, if they have libraries working with other databases. As for the alternatives to SQLite, here are some: HDF5 (not really a database), number of key-value storage programs, http://en.wikipedia.org/wiki/List_of_in-memory_databases and some graph databases (whitedb for example) can be used in this way. – wvxvw Feb 24 '15 at 19:59

1 Answers1

3

The most popular package on MELPA is esqlite. Here's a simple example of its usage:

(require 'esqlite)
(esqlite-read "database.sqlite" "SELECT * FROM hoge")

Your other option is the sqlite package, also from MELPA. An example snippet with that packages API is:

(require 'sqlite)

(let ((descriptor (sqlite-init "~/mydb.sqlite")))
    (setq res (sqlite-query descriptor "SELECT * FROM persona"))
    (sqlite-bye descriptor)
    res)

abo-abo also pointed out the more powerful emacsql package which is more can interface with other RDBMS (including MySQL, and SQLite). Of the packages described here, emacsql has the most abstract API (where queries are represented as objects instead of raw strings). Here's an example of its usage:

(require 'emacsql)
(defvar db (emacsql-connect "~/company.db"))

;; Query the database for results:
(emacsql db [:select [name id]
             :from people
             :where (> salary 62000)])

There are probably even more solutions. The question, then, comes down to which package supports the methods you need, and which API you like the most.

PythonNut
  • 10,243
  • 2
  • 29
  • 75