clx_import
for MariaDB Xpand
This page is part of MariaDB's Documentation.
The parent of this page is: Data Import with MariaDB Xpand
Topics on this page:
Overview
clx_import
is a tool for quickly migrating data from various data sources into an Xpand database. It has 3 modes of operation:
(fastest) Import a SQL file created by
mysqldump
(similar tocat file | mysql
, but much faster)import single delimiter-separated file, similar to mysql's
LOAD DATA INFILE
functionalityImport several delimiter-separated files in parallel
clx_import
will examine the source file and estimate how tables should be sliced. However, this is just an estimate that does not fully account for the different ways in which data is represented. In most cases, the Rebalancer will further optimize the data balance after the import, which may impact initial performance. For additional information, see "Manage the Rebalancer for MariaDB Xpand".
Exporting data from another database
If you are unsure which format to export, use mysqldump
with no special options other than the user, password, and tables or DBs to dump, and import with clx_import --sql-file
.
If you have a character set other than utf8 set via my.cnf
, invoke mysqldump
with --default-character-set utf8
. This will not change the character set of the data, or future connections by any application.
Importing from a mysqldump
To import a database exported using mysqldump
:
shell> clx_import -u username -H hostname_or_ip -p --sql-file filename
Depending on if the dump file contains USE
directives , you may need to specify the target database using the option for --db
.
Importing from a delimiter-separated file:
To import a delimiter-separated value into an existing table:
shell> clx_import -u username -H hostname_or_ip -p --ldi ldi_definition
Depending on if the dump file contains USE
directives , you may need to specify the target database using the option for --db
.
Where ldi_
--ldi "'file_name'
[REPLACE | IGNORE]
INTO TABLE tbl_name
[CHARACTER SET charset_name]
[{FIELDS | COLUMNS}
[TERMINATED BY 'char']
[[OPTIONALLY] ENCLOSED BY 'char']
[ESCAPED BY 'char']
]
[LINES
[STARTING BY 'string']
[TERMINATED BY 'string']
]
[IGNORE number num_lines]"
Because the whole ldi definition must be a single shell arguments. Since it contains several quote values, it is recommended that it be enclosed in double quotes. Because of this, if tbl_
If no values for FIELDS or LINES are specified, the behavior will be as though the following was specified:
FIELDS TERMINATED BY 't' ENCLOSED BY '' ESCAPED BY '\' LINES TERMINATED BY 'n' STARTING BY ''
Import multiple delimiter-separated files:
To import several delimiter-separated values at once, create an empty directory containing one file called ddl.sql
containing CREATE TABLE
statements for the tables to be imported. Then create one file per table in said directory with the same name as the table it contains data for. Once this is arranged, invoke clx_import
as:
shell> clx_import -u username -H hostname_or_ip -db database -p --csv-dir path_to_data --csv-options csv_options
Where path specified contains ddl.sql
and the data files. Tbe csv_INTO TABLE
clause.
Note
Note: When importing multiple files at once, they all must use the same delimiter.
clx_import
options
clx_import
supports several other options that can be used in various circumstances, but the common use case shouldn't require these:
|
If ddl.sql or the sqldump file contains |
| Failed INSERT statements will be added to this file. Defaults to a temp file that will be printed at the end of the import |
| Logs from the import itself will be put here (i.e. the information shown on the screen during import), defaults to a temp file |
| Statements run by the importer will not be binlogged |
| Issues |
| Normally |
| A .sql file to be executed after tables are created and autoslicing has been done, but before any inserts. This file does not support |
Differences between clx_import
and LOAD DATA INFILE
:
Notable differences between this and standard LOAD DATA INFILE
is that
setting individual columns (via a
SET
clause) is not supportedThe field terminator must be a single character (rather than an arbitrary string)
The line terminating character must be some sort of newline (r, n, or rn) but multiple newlines is not supported
LOW PRIORITY
andCONCURRENT
are not supportedclx_import
does not support importing tables withALLNODES
. Use Backup and Restore instead.
Caveats for clx_import
clx_import
does not support importing dump files collected using the options--complete-insert
or--replace
clx_import
requires Python 2.7