Exporting Database Records

Introduction

MGI stores database information in a proprietary database format for the database that is built into the MGI code. However, you can use the export and import features of the mgiEditDatabase tag to move database records between different programs or to easily edit existing data or database structures. MGI exports records in a standard tab-delimited format.

MGI Tags

Steps

  1. Create a database administration page in a text editor.
  2. Insert the mgiEditDatabase tag.
  3. Save the database administration page.
  4. FTP the database administration page to the web server running MGI.
  5. View the database administration page in a web browser.
  6. Select a database.
  7. Export the database records.


Step 1: Create a database administration page in a text editor.

Create a new page in a text editing program to display the web-based, database administration interface.

Step 2: Insert the mgiEditDatabase tag.

On the database administration page, enter the mgiEditDatabase tag.
<mgiEditDatabase>

Step 3: Save the database administration page.

Save the database administration page and name it "dbadmin.mgi".

Step 4: FTP the database administration page to the web server running MGI.

Upload the database administration page (dbadmin.mgi) from your local computer to the web server using an FTP program.

Step 5: View the database administration page in a web browser.

View the database administration page (dbadmin.mgi) in a browser. The first screen of the web-based, administration interface is displayed.

Step 6: Select a database.

Below "Select a database", click the radio button beside the database you wish to export and click the "Records" button. The record screen of the administration interface displays.

Step 7: Export the database records.

In the record screen of the administration interface, click the "Export" button. The export interface displays:

Beside "Filename", enter the name of the file to export. Exported files are saved to the web server in the same folder as the database administration page. Use a unique name if you do not wish to overwrite an existing file.
 
By default, database records are exported in the order of the original field creation and are sorted by the order entered.
 
To change the field order of the export, enter the numerical position for each field under "Position" (e.g., "1", "2". etc.). Any fields that are left blank will be added to the end of the specified field order and will be exported in the order they appear. To keep a field from being exported, place an "X" in the field under "Position".
 
To change the sorting of records for the export, select a field to use for the sort under "Order". To change the sort from ascending (A to Z, smallest to largest) to descending (Z to A, largest to smallest), check the box under "Rev" beside the field you have chosen for the sort.
 
Click the "Export Now" button to export the records. Records are exported to the specified file on the web server. When the export is complete the search interface of the database administration displays. The exported file is written in tab-delimited format to the same folder as the database administration page. You may use an FTP program to download the exported file.
 
The first line of the exported file contains a comment "!Generated by MGI!". The second line of the exported file contains the field definitions (in parentheses) to the left of each field name. Each type of MGI field (text, long text, boolean, etc.) is represented by a letter:
  • B - True/False (Boolean)
  • I - Whole Number (Integer)
  • U - Positive Number (Unsigned Integer)
  • N - Decimal Number (Multi-Precision Float)
  • T - Text
  • L - Long Text
Text and decimal number fields are followed by the specified number of characters or decimal places. Field definitions with an "X" are indexed. Field definitions with a "Q" are unique.
 
The remaining lines in the exported file are the tab-delimited data of each record. All lines in the exported file end with a carriage return (Mac) or carriage return/line fee (NT).
 
The following is an example exported file. The text in this example is wrapped for viewing purposes, however each record is actually only one row of tab-delimited text. The triangles in this example represent tabs and the horizontal lines as the end of each row represent a carriage return.


Comments and Notes

The mgiEditDatabase tag gives you and anyone who views the page in a web browser access to modify databases. Keep your databases secure by password-protecting the database administration page with an mgiAuthenticate or mgiAuthenticateDB tag.


[Return to the Creating and Populating Databases Menu]


[Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]


[MGI Guides Main Menu] [User Guide Main Menu]