Setting up Emacs Photo Database

In order to use Emacs Photo Database, you'll have to perform the following steps. First, create a suitable SQL database. Second, add some lines to your .emacs file to load and initialize the package.

Create the Database

Create an empty SQL database to store your data. The procedure depends on the database engine you use. This section provides the procedures for SQLite and for MySQL. Other engines will require some adjustments in the procedures as well as in the SQL scripts.


SQLite creates the database the first time you access it. All you need to do is to create the tables by running the provided SQL script. Replace the second argument ("DBPATH") with the full path of the database file. You can put it anywhere as long as you have write access.

	    ~$ sqlite3 DBPATH < photo.sqlite.sql


MySQL requires some more work as we have to create the database, allow you to access it, and then create the tables. Remember that you have to run the first two commands with database administrator permissions. "DBNAME" is the name of your database.

	    ~$ mysql -u ADMIN --password=ADMINPASSWD -e "create database DBNAME"
	    ~$ mysql -u ADMIN --password=ADMINPASSWD -e "grant all on DBNAME.*
	          to 'USERNAME'@'localhost'"
	    ~$ mysql -u USERNAME --password=PASSWD -D DBNAME < photo.mysql.sql

Modify your .emacs

In order to access the database from Emacs you'll have to load the package either from your .emacs or from a global startup file (default.el or site-start.el). To this end, load the package from one of the startup files like this:

(require 'ephotodb)

Next you have to tell the package how to access the SQL database you've just created. Provide a full command to run database queries against your database engine, excluding the query string proper which ephotodb will provide. The following line uses the SQLite version 3 client:

(setq photo-dbclient-command "sqlite3 DBPATH")

Use the full path instead of just the program name if it is not in your PATH. Other database engine clients require additional arguments. The following line works with MySQL (all in one line):

(setq photo-dbclient-command "mysql -u USERNAME --password=PASSWD
   -D DBNAME --silent --skip-column-names -e")