6.0.0-git
2024-04-18
Last Modified 2007-01-09 by Jan Schneider

Importing data into Turba's address book

This is a small MySQL script to import address book data from IMP 2 into Turba 2's default SQL address book. You can tweak the code to import data from any other external database tables. Please adapt it to your needs before running it.


INSERT INTO turba_objects

    (object_id, owner_id, object_uid, object_name, object_alias, object_email)

    SELECT

        MD5(CONCAT(user, fullname, address)),

        SUBSTRING(user, 1, LOCATE('@', user) - 1),

        CONCAT(MD5(CONCAT(user, fullname, address)), '@example.com'),

        fullname,

        nickname,

        address

        FROM imp_addr WHERE user LIKE '%@localhost' OR user LIKE '%@example.com'

This code takes all entries from the imp_addr table that have the user name ending with @localhost or @example.com. This domain part is then stripped from the user name (SUBSTRING(...)), unique ids are created using the user, fullname, and address columns, the fullname, nickname, and address columns are taken as-is and everything is inserted into the turba_objects table.

Please note that Turba is usually flexible enough to connect to any existing address book, you do not have to use the table scheme that is shipped with Turba. This script only makes sense if you don't need the old address book anymore, or need some of the features or fields provides with newer Turba versions.