Next: , Previous: Configuring Elephant, Up: Installation


3.3 Loading Elephant

3.3.1 Loading Elephant via ASDF

Now that you have loaded all the dependencies and created your configuration file you can load the Elephant packages and definitions:

     (asdf:operate 'asdf:load-op :elephant)

This will load the cl-base64 and uffi libraries. It will also automatically compile and load the C library. The build process no longer depends on a Makefile and has been verified on most platforms, but if you have a problem please report it, and any output you can capture, to the developers at elephant-devel@common-lisp.net. We will update the FAQ at http://trac.common-lisp.net/elephant with common problems users run into.

3.3.2 Two-Phase Load Process

Elephant uses a two-phase load process. The core code is loaded and the code for a given data store is loaded on demand when you call open-store with a specification referencing that data store. The second phase of the load process requires ASDF to be installed on your system.

(NOTE: There are some good reasons and not so good reasons for this process. One reason you cannot load ele-bdb.asd directly as it depends on lisp code defined in elephant.asd. We decided not to fix this in the 0.9 release although later releases may improve on this).

3.3.3 Packages

Now that Elephant has been loaded, you can call use-package in the cl-user package,

     CL-USER> (use-package :elephant)
     => T

use a predefined user package,

     CL-USER> (in-package :elephant-user)
     => T
     
     ELE-USER>

or import the symbols into your own project package from :elephant.

     (defpackage :my-project
       (:use :common-lisp :elephant))

The imported symbols are all that is needed to control Elephant databases and are documented in detail in User API Reference

3.3.4 Opening a Store

As discussed in the tutoral, you need to open a store to begin using Elephant:

     (open-store '(:BDB "/Users/owner/db/my-bdb/"))
     ...
     ASDF loading messages
     ...
     => #<BDB-STORE-CONTROLLER>
     
     (open-store '(:CLSQL (:POSTGRESQL "localhost.localdomain"
                                       "mydb" "myuser" ""))))
     ...
     ASDF loading messages
     ...
     => #<SQL-STORE-CONTROLLER>

The first time you load a specific data store, Elephant will call ASDF to load all the specified data store's dependencies, connect to a database and return the store-controller subclass instance for that data store.