]> git.phdru.name Git - sqlconvert.git/blob - docs/mysql2sql.rst
0035c555f29d7c7e528763f12ca6d982cf641d15
[sqlconvert.git] / docs / mysql2sql.rst
1 mysql2sql
2 =========
3
4 This is mysql2sql, a mysql to sql converter. It is primary intended to
5 convert mysqldump (especially with extended INSERT syntax) to standard
6 SQL to load at least to PostgreSQL or SQLite.
7
8 The program is in the early stage of development and currently cannot do much.
9 It removes /\*! directives \*/, unescapes strings and escapes them to a
10 different quoting style, and passes everything else unmodified.
11
12
13 .. highlight:: none
14
15 Command line
16 ------------
17
18 mysql2sql
19 ~~~~~~~~~
20
21 Usage::
22
23     mysql2sql [-e encoding] [-E output_encoding] [-m/-p/-s] [infile] [[-o] outfile]
24
25 Options::
26
27     -e ENCODING, --encoding ENCODING
28                            input/output encoding, default is utf-8
29     -E OUTPUT_ENCODING, --output-encoding OUTPUT_ENCODING
30                            separate output encoding, default is the same as
31                            `-e` except for console; for console output charset
32                            from the current locale is used
33     -m, --mysql            MySQL/MariaDB quoting style
34     -p, --pg, --postgres   PostgreSQL quoting style
35     -s, --sqlite           Generic SQL/SQLite quoting style (default)
36     -P, --no-pbar          Inhibit progress bar
37     infile                 Input file, stdin if absent or '-'
38     -o, --outfile outfile  Output file, stdout if absent or '-'
39
40 Options `-m/-p/-s` change quoting style. `-m` sets MySQL quoting style; it's
41 added to use the program in the following scenario: convert MySQL dumps with
42 extended INSERTs to SQL with plain INSERTS suitable to be fed back to MySQL.
43 `-p` sets PostgreSQL quoting style; it's like MySQL with additional `E''-style
44 quoting
45 <https://www.postgresql.org/docs/9.1/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE>`_.
46 `-s` sets generic SQL/SQLite quoting style; this is the default.
47
48 If stderr is connected to the console the program displays a text mode progress
49 bar. Option `-P/--no-pbar` inhibits it.
50
51 Option `-o` is useful when infile is absent (input is redirected), for
52 example::
53
54     mysql2sql -o outfile.sql < infile.sql
55     cat infile.sql | mysql2sql -o outfile.sql
56
57 But of course it simply can be::
58
59     mysql2sql - outfile.sql < infile.sql
60     cat infile.sql | mysql2sql - outfile.sql