ltuldr

ltuldr — Compatible with ORACLE, obtaining all information of a table from the LightDB database.

Synopsis

ltuldr [connection-option...] [option...]

Description

ltuldr is a small and flexible tool that export LightDB data. It can directly export all data of a specified table, or use SQL statement to export specific data.

ltuldr can specify the format of the exported data. This includes the separator of field and field, row and row.

The file formats currently supported by ltuldr, including txt and csv, can also output data directly to standard devices.

ltuldr supports writing logs to specified files.

Options

The following command-line options control the content and format of the output.

user=

Specify the user who exports the table.

dbname=

Specify the dbname who exports the table.

host=

Specify the host who exports the table.

port=

Specify the port who exports the table.

password=

Specify the password who exports the table.

query=

Specify the information to export the table. You can use the table name directly or use SQL statements.

Query and connection information are necessary for ltuldr. You can also use the following sql parameters to specify SQL statements.

sql=

Specify the file address of the SQL statement, which should be used together with the connection information.

If the SQL statement is very complex or long, it is difficult to specify it on the command line. At this time, you can write a SQL file containing complex SQL (note that there should be no semicolon or backslash at the end of the SQL statement), and then tell the user to read the complex SQL statement from the specified SQL file for data export.

The sql parameter and query parameter cannot be used together.

field=

Specify the separator between fields in the export file. The default value is ',';

The field separator is usually one character, but it can actually be multiple characters; In addition, visible, printable characters, strings, and invisible characters can be used as separators.

record=

Specify the separator between lines in the export file. The default value is '\n';

The record and file separators are named in the same way.

file=

Specify the name of the exported file. If the first character of the file surface is a plus sign (+), it means that added after the existing file. Otherwise, a new file will be generated. If there is already a file with the same name, the existing file will be overwritten. If not specified, the default is lowercase "uldrdata. txt". The storage path is the current directory where ltuldr is running.

There are several special format codes in the file option, which can be used to specify dynamic file names (with date information in the generated file names). Reasonable use of these format codes can meet some specific needs and reduce the workload of script writing. %Y、%y:four digit year representing the current time; %M、%m:the two digit month representing the current time; %D、%d:two digit day representing the current time; %W、%W:the number representing days in a week at the current time; %B、%b:500000 is a batch, which is also related to the option batch. If batch is 2, the count will be increased by one for every 1 million exported.

log=

Specify the file for the exported log. Other usage is the same as file paramter, except that %B and %b are not allowed by log files.

batch=

Specify the maximum saved batch of a file, 500000 is a batch. When writing files in batches, the file name must be dynamic, preferably with %B and %b added. Otherwise, the data in the original file will be overwritten.

Examples

Connect to the database, query the pg_class table and write the results to the default file uldrdata. txt:

$ ltuldr user=lightdb dbname=postgres host=127.0.0.1 port=5432 password=1 query=pg_class

Write the results to the specified file lightdb. txt:

$ ltuldr user=lightdb dbname=postgres host=127.0.0.1 port=5432 password=1 query=pg_class file=lightdb.txt

Write the log file to the dynamic file %Y_%M_%D.log:

$ ltuldr user=lightdb dbname=postgres host=127.0.0.1 port=5432 password=1 query=pg_class file=lightdb.txt log=%Y_%M_%D.log

All fields in the table are written to the file lightdb. txt:

$ ltuldr user=lightdb dbname=postgres host=127.0.0.1 port=5432 password=1 query=pg_class file=lightdb.txt log=%Y_%M_%D.log head=yes

Get the data of two batches at a time and write it to the file lightdb. txt:

$ ltuldr user=lightdb dbname=postgres host=127.0.0.1 port=5432 password=1 query=pg_class file=lightdb.txt log=%Y_%M_%D.log head=yes batch=2