SQL Dump Export

From WandoraWiki
Jump to: navigation, search

SQL Dump Export tool is used to export topic map as SQL insert statements that can be imported to a relational database.

Exporting topic map

To start the tool, select File > Export > SQL Dump Export menu option. This will export whole layer stack. You can also right click a single layer and select the tool in the context menu to export only that layer. Select the file where you want to write the SQL statements. The tool will create some temporary files during export in the default temp directory of your operating system.

Importing statements

To import the statements, you need to first create the SQL database and tables as described in Database topic map. However, you can greatly increase import speed if you create indexes only after you have imported all statements. The default database scripts contain create index statements at the end of the script. You should make a copy of the script and remove these statements. Then run the statements after you have imported the SQL dump file. Depending on your database configuration, you may be able to speed up the import in some other ways too. Refer to your database documentation.

Note that you should import the statements in an empty database or otherwise take care that the resulting database contents describe a valid topic map. Specifically if the database is not empty, the imported statements could contain topics that merge with existing topics. Such a database would result in erratic behavior if it is used as a database topic map in Wandora.

Running from command line

You can also run the tool from command line. The command line version will convert a topic map in XTM 2.0 format to sql statements. Note that the topic map must be in version 2.0 of XTM. The tool is also somewhat picky about what kind of constructs it understands. Specifically it will skip constructs that are not supported by the Reduced Topic Maps used in Wandora. The tool does not read the entire topic map in memory so you should be able to convert topic maps that are too big to fit in memory in Wandora application. This is the main advantage of using the command line version.

The tool will read XTM from standard input and write results to standard output, this means that you most likely want to redirect these to and from some files. The tool will print information about the process in standard error stream. The class to run is org.wandora.application.tools.exporters.SQLDumpExport. For example, to read input.xtm and write to out.sql you would run

java org.wandora.application.tools.exporters.SQLDumpExport < input.xtm > out.sql
Personal tools