LDM Import Export
From EIRMA Wiki
| Quick Links |
|---|
|
Overview and Tutorial |
|
Pre-Installation Installation Post-Installation |
|
Administration |
|
Moderation Design Advanced |
|
Other |
Contents |
LDM can import and export its database using xml formatted files, and can also import simple information using a .csv formatted file. The xml format is more flexible and is recommended. The csv import has been removed in version 3.0 of LDM.
Exporting Entries
- LDM->Admin->Import and Export Export XML provides a way to backup the database contents, including administration settings, excluding the (often very large) downloads table. (Download records can be exported via the LDM/Admin/Hits page.) The exported files can then be re-imported, retaining the main contents of your database. (Currently, favourites and ratings/comments are not imported.)
Importing Entries
- LDM->Admin->Import and Export Import XML imports an xml file, either previously exported from LDM or manually constructed. The import command includes options to first empty the database, and/or to clear the admin settings. This provides a way to transfer the contents of a database to another machine, to graft databases together, and to add new items in bulk to the database.
- The option "Just update existing entry names and descriptions based on url" provides a way to update existing entries. When this option is selected, all information in the xml file is ignored with the exception of entry titles, descriptions and urls. The contents of the xml file are compared to the contents of the current database, and existing entries with matching urls are updated so that their titles and descriptions match the information in the import file.
XML file format
The file format is straightforward, but easiest to understand by creating and editing a sample file. It contains entity definitions for the common HTML special characters, followed by a series of sections defining administrative settings, categories, entries (links), category membership, entities, keywords, favourites and ratings. Example xml files are provided in the /release/tests diretory of the release zip file.
Not all the sections are required in order to carry out an import. The <links>, <cats>, and <linkcats> sections are always required, and the entity definitions are only required if you use HTML special characters. Other sections (<keywords>, <linkkeys>, <entities>, <favourites> and <ratings>) can be included or omitted as desired. The numbering of entries, categories, etc, in the xml file is arbitrary, provided it is consistent with the structure you seek to achieve. It is essential to follow the standard rules for valid XML files (i.e. tags must be properly nested and closed, characters such as amperand must be escaped, and special characters pre-defined in the entities section).
Importing using .csv files [deprecated and removed in version 3.x]
CSV imports can be used as a "quick and dirty" way to import information about categories and entries into the database. This information is sufficient to create an initial structure, but not sufficient to restore a full database.
The .csv file contains records defining categories, entries and the categories in which the entries are placed. Category records can only be imported into an empty database: *all* category records in the file will be skipped if the database already contains *any* categories. Entry records can be imported regardless of whether there are already entries in the database, although attempts to import entries into non-existent categories will fail.
Example (see sample.csv)
category,1,Media,"Television, Radio and Newspapers","-1" link,New York Times,http://www.nytimes.com,"The New York Times, a leading US newspaper",1 link,BBC,http://www.bbc.co.uk,the beeb,1 link,ITV,http://www.itv.co.uk,its main rival,1
The category records contain these fields:
category,cat_id,cat_name,cat_desc,parent_list,cat_forumid
- The first field contains the word "category".
- cat_id is an integer
- cat_name and cat_desc are text fields
- parent_list is a comma-separated list (surrounded by quotes) giving the hierarchy through the category tree and always ending with -1, the root
- cat_forumid is the associated forum, is optional and defaults to the current default forumid
The entry records contain these fields:
link,link_name,link_url,link_desc,link_catid,link_forumid,link_image,link_reviewfreq
- The first field contains the word "link".
- link_name, link_url, link_desc and link_img are text fields
- link_catid, link_forumid and link_reviewfreq are numbers
- link_forumid is optional and defaults to the current default forumid link_img and link_reviewfreq are also optional
Fields can be surrounded by double quotes. The import process includes some error checking. New entries are marked as "not yet validated".
