[cvs] [Wiki] created: TurbaImportAddressBook
Jan Schneider
jan at horde.org
Tue Jan 9 05:00:11 PST 2007
jan Tue, 09 Jan 2007 05:00:11 -0800
Created page: http://wiki.horde.org/TurbaImportAddressBook
+ 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.
<code type="sql">
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'
</code>
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.
More information about the cvs
mailing list