Datafiles

Sqlch datafiles are written in a custom format. The character encoding of a datafile is fixed as UTF-8. Sqlch deliberately does not use an XML format for the datafiles for the following reasons:

Format details

Each line of a datafile is terminated with a new line (appropriate for the current platform, e.g. LF for most unix systems, CR LF for Windows/DOS).

Each line is made up of free text values separated by a pipe delimiter ("|").

The first line of the file lists the column names of the table to be loaded.

The subsequent lines consists of row data. Each piece of row data is quoted using double quotes (") and escaped. An empty value indicates null, a zero-length String is represented by a pair of quotes ("").

The final line of data in a file must be terminated with a new line followed by the end-of-file.

Escape Codes

Whitespace characters are escaped using standard Java escape codes (except for \|, which is used to escape the column delimiter):

Escape code Meaning
\r Carriage return
\n New line
\t Tab
\\ \
\" Double quote
\| |

Row Format Example:

The following is an extract of a datafile with examples of the various types of String. The values themselves are determined by the datatype of column.

"One"|"Two"|"Three"
""|"Four"|
|"Five"|""
"Six"||""
Remember - the quotes are important.

This example defines the following String values:

Column one value Column two value Column three value
One Two Three
{Empty string} Four {Null}
{Null} Five {Empty String}
Six {Null} {Empty String}

Note: Some databases (e.g. Oracle) do not make a distinction between the empty string ("") and null and simply store a zero length String as null. In this case, a value inserted as an empty string will be saved back out as a null value.



SourceForge.net Logo

Sqlch SourceForge Distribution: 0.1Alpha8 20041026 2208