next up previous contents index
Next: 7. Sympa with S/MIME and HTTPS Up: Sympa Mailing Lists Management Software Previous: 5. WWSympa   Contents   Index

Subsections


6. Using Sympa with a RDBMS

It is possible for Sympa to store its user information within a Relational DataBase System. Currently you can use one of the following DBMS : MySQL, PostgreSQL, Oracle, Sybase. Interfacing with other RDBMS requires only a few changes in the code since the API used, DBI (DataBase Interface), has DBD (DataBase Drivers) for many DBMS.

6.1 Prerequisites

You need to have a DataBase System installed (not necessarily on the same host as Sympa) and the client librairies for that Database installed on the machine, as far as a Perl DBD (DataBase Driver) is provided for it. Check the DBI Module Availability.

6.2 Installing Perl modules

Sympa will use DBI to communicate with the database system and therefore requires the DBD for your database system. DBI and DBD::YourDB (Msql-Mysql-modules for MySQL) are distributed as CPAN modules. Refer to  [*], page [*] for installation details of these modules.

6.3 Creating sympa DataBase

6.3.1 Database structure

The sympa database structure is slightly different from the structure of a subscribers file. A subscribers file is a text file based on paragraphs (almost similar to the config file) ; each paragraph completely describes a subscriber. If somebody is subscribed to two lists, he/she appears in both subscribers files.

The DataBase distinguishes information relative to a person (email, real name, password) and his/her subscription options (list concerned, date of subscription, reception option, visibility option). This results in separating the data in two tables : user_table and subscriber_table joined together by a user/subscriber email.

6.3.2 Database creation

create_db script below will create the sympa database for you. You can find it in the script/ directory of the distribution (currently scripts are available for mysql, postgresql, Oracle and Sybase).

## MySQL Database creation script
CREATE DATABASE sympa;

## Connect to DB 
\r sympa

CREATE TABLE user_table (
  	email_user          	varchar (100) NOT NULL,
  	gecos_user          	varchar (150),
  	password_user		varchar (20),
	cookie_delay_user	int,
	lang_user		varchar (10),
	PRIMARY KEY (email_user)
);

CREATE TABLE subscriber_table (
  	list_subscriber       	varchar (50) NOT NULL,
	user_subscriber		varchar (100) NOT NULL,
	date_subscriber		datetime NOT NULL,
	visibility_subscriber	varchar (20),
	reception_subscriber	varchar (20),
	bounce_subscriber	varchar (30),
	update_subscriber 	datetime,
	PRIMARY KEY (list_subscriber, user_subscriber)
);

You can execute the script using a simple SQL shell such as mysql or psql.

Example:

# mysql  < create_db.mysql

6.3.3 Importing data from subscribers files

You might need to import subscribers data from an older version of Sympa into sympa database. Simply edit the list configuration using WWSympa (this requires listmaster privileges) and change the data source from file to database.

6.4 Sympa configuration

To store subscribers information in your newly created database, you first need to tell Sympa what kind of database he's going to work with, then you must configure your list to work with the database.

You define the database source in sympa.conf : db_type, db_name, db_host, db_user, db_passwd.

If you are interfacing Sympa with an Oracle database, db_name is the SID.

All your lists are now configured to use the database, unless you set list parameter user_data_source to file or include.

Sympa will now extract and store user information for this list from the database instead of using subscribers file. Though subscribers information are dumped in subscribers.db.dump at every shutdown to allow hand rescue restart (by renaming subscribers.db.dump to subscribers and changing user_data_source parameter) if the database is out of order.


next up previous contents index
Next: 7. Sympa with S/MIME and HTTPS Up: Sympa Mailing Lists Management Software Previous: 5. WWSympa   Contents   Index
root 2000-12-14