sqlite_drv: SQLite storage driver for DSPAM <jonathan@nuclearelephant.com>
Copyright (c) 2004 Network Dweebs Corporation
http://www.nuclearelephant.com/projects/dspam/

LICENSE

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

ABOUT

sqlite_drv is a SQLite storage driver for DSPAM v3.0 and above.  This driver
enables DSPAM to read and write all token, signature, and statistics data
from individual SQLite databases created for each user.

WARNING: SQLite is not designed to function over NFS. If your system is large            enough to require NFS, it is strongly recommended you use a stateful
         SQL driver, such as MySQL or PostgreSQL.

1. CONFIGURING DSPAM

To configure DSPAM to use sqlite_drv, use the following arguments while running
DSPAM's configure:

--with-storage-driver=sqlite_drv 
Tells DSPAM to use the sqlite_drv driver

--with-sqlite-libraries=/path/to/libs
Tells DSPAM where to find the SQLite library (libsqlite.so).

--with-sqlite-includes=/path/to/includes
Tells DSPAM where to find the SQLite headers.

After configure has successfully finished, build and install DSPAM using the
instructions from DSPAM's readme. 

2. OBJECT CREATION

sqlite_drv will automatically create the necessary database objects for each
user upon first use of DSPAM by that user.

3. PURGING

The purge script should be run against all databases periodically. The best
way to do this is to use a find recipe such as:

find /var/dspam/data -name "*.sdb" -exec sqlite {} < /var/dspam/purge.sql \;

You may also wish to occasionally compact your databases. This should only
be run once in a great while, and is not entirely necessary as sqlite will
automatically reclaim space the next time it is used.  Nevertheless, some
databases can grow quite large if not purged well enough. Another find
recipe such as the one below can be used to compact all databases on a
system.

find /var/dspam/data -name "*.sdb" -exec echo 'vacuum;' \| sqlite {} \;

4. TUNING

There are some tuning parameters which can be set, discussed here:
http://sqlite.org/lang.html#pragma

Whenever sqlite_drv connects to a database, it will read 
$DSPAM_HOME/sqlite.pragma and execute any commands found in the file. For
example, if you wish to turn off synchronous mode (which speeds up queries by
as much as 50x, but could potentially risk database corruption on system
crash), you could add this line to sqlite.pragma:

PRAGMA synchronous = OFF

Note: Do not put a semicolon at the end of any statements in sqlite.pragma. 

ERRORS

Any SQL errors will be reported to /tmp/sql.errors as well as the standard
syslog facilities (although the query will be truncated).

QUESTIONS

Please contact the dspam-dev mailing list with any questions or constructive
feedback.

Jonathan A. Zdziarski
<jonathan@nuclearelephant.com>
