comparison docs/scripts/html/DBSchemaTablesToTextFiles.html @ 0:4816e4a8ae95 draft default tip

Uploaded
author deepakjadmin
date Wed, 20 Jan 2016 09:23:18 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4816e4a8ae95
1 <html>
2 <head>
3 <title>MayaChemTools:Documentation:DBSchemaTablesToTextFiles.pl</title>
4 <meta http-equiv="content-type" content="text/html;charset=utf-8">
5 <link rel="stylesheet" type="text/css" href="../../css/MayaChemTools.css">
6 </head>
7 <body leftmargin="20" rightmargin="20" topmargin="10" bottommargin="10">
8 <br/>
9 <center>
10 <a href="http://www.mayachemtools.org" title="MayaChemTools Home"><img src="../../images/MayaChemToolsLogo.gif" border="0" alt="MayaChemTools"></a>
11 </center>
12 <br/>
13 <div class="DocNav">
14 <table width="100%" border=0 cellpadding=0 cellspacing=2>
15 <tr align="left" valign="top"><td width="33%" align="left"><a href="./CalculatePhysicochemicalProperties.html" title="CalculatePhysicochemicalProperties.html">Previous</a>&nbsp;&nbsp;<a href="./index.html" title="Table of Contents">TOC</a>&nbsp;&nbsp;<a href="./DBSQLToTextFiles.html" title="DBSQLToTextFiles.html">Next</a></td><td width="34%" align="middle"><strong>DBSchemaTablesToTextFiles.pl</strong></td><td width="33%" align="right"><a href="././code/DBSchemaTablesToTextFiles.html" title="View source code">Code</a>&nbsp;|&nbsp;<a href="./../pdf/DBSchemaTablesToTextFiles.pdf" title="PDF US Letter Size">PDF</a>&nbsp;|&nbsp;<a href="./../pdfgreen/DBSchemaTablesToTextFiles.pdf" title="PDF US Letter Size with narrow margins: www.changethemargins.com">PDFGreen</a>&nbsp;|&nbsp;<a href="./../pdfa4/DBSchemaTablesToTextFiles.pdf" title="PDF A4 Size">PDFA4</a>&nbsp;|&nbsp;<a href="./../pdfa4green/DBSchemaTablesToTextFiles.pdf" title="PDF A4 Size with narrow margins: www.changethemargins.com">PDFA4Green</a></td></tr>
16 </table>
17 </div>
18 <p>
19 </p>
20 <h2>NAME</h2>
21 <p>DBSchemaTablesToTextFiles.pl - Export table data from database SchemaName(s) into CSV/TSV text files</p>
22 <p>
23 </p>
24 <h2>SYNOPSIS</h2>
25 <p>DBSchemaTablesToTextFiles.pl SchemaName(s)...</p>
26 <p>DBSchemaTablesToTextFiles.pl [<strong>-d, --dbdriver</strong> mysql | Oracle| Postgres or Pg] [<strong>--dbhost </strong> hostname]
27 [<strong>--dbname</strong> databasename] [<strong>--dbpassword</strong> password] [<strong>--dbusername</strong> username]
28 [<strong>--exportdatalabels</strong> yes | no] [<strong>--exportlobs</strong> yes | no] [<strong>-h, --help</strong>]
29 [<strong>-m, --mode</strong> exportdata | describetable] [<strong>-n, --numoutfilesmode</strong> single | multiple]
30 [<strong>-o, --overwrite</strong>] [<strong>--outdelim</strong> comma | tab | semicolon]
31 [<strong>-q, --quote</strong> yes | no] [<strong>-r, --root</strong> rootname] [<strong>--replacenullstr string</strong>]
32 [<strong>-w --workingdir</strong> dirname] SchemaName(s)...</p>
33 <p>
34 </p>
35 <h2>DESCRIPTION</h2>
36 <p>Export table data from database SchemaName(s) into CSV/TSV text files. Use <strong>-n --numoutfiles</strong>
37 option to control the number of text files generated for a database schema.</p>
38 <p>
39 </p>
40 <h2>OPTIONS</h2>
41 <dl>
42 <dt><strong><strong>-d, --dbdriver</strong> <em>mysql | Oracle | Postgres or Pg</em></strong></dt>
43 <dd>
44 <p>Database driver name. Possible values: <em>mysql, Oracle, Postgres or Pg</em>. Default: <em>MySQL</em> or value of
45 environment variable DBI_DRIVER. This script has only been tested with MySQL, Oracle
46 and PostgreSQL drivers.</p>
47 </dd>
48 <dt><strong><strong>--dbhost </strong> <em>hostname</em></strong></dt>
49 <dd>
50 <p>Database host name. Default: <em>127.0.0.1</em> for both MySQL and Oracle. For remote
51 databases, specify complete remote host domain: <em>dbhostname.org</em> or something
52 like it.</p>
53 </dd>
54 <dt><strong><strong>--dbname</strong> <em>databasename</em></strong></dt>
55 <dd>
56 <p>Database name. Default: mysql for MySQL, postgres for PostgreSQL and none for Oracle.
57 For connecting to local/remote Oracle databases, this value can be left undefined assuming
58 <strong>--dbhost</strong> is correctly specified.</p>
59 </dd>
60 <dt><strong><strong>--dbpassword</strong> <em>password</em></strong></dt>
61 <dd>
62 <p>Database user password. Default: <em>none</em> and value of environment variable DBI_PASS
63 is used for connecting to database.</p>
64 </dd>
65 <dt><strong><strong>--dbusername</strong> <em>username</em></strong></dt>
66 <dd>
67 <p>Database user name. Default: <em>none</em> and value of environment variable DBI_USER is
68 used for connecting to database.</p>
69 </dd>
70 <dt><strong><strong>--exportdatalabels</strong> <em>yes | no</em></strong></dt>
71 <dd>
72 <p>This option is mode specific and controls exporting of column data labels during
73 exportdata mode. Possible values: <em>yes or no</em>. Default: <em>yes</em>.</p>
74 </dd>
75 <dt><strong><strong>--exportlobs</strong> <em>yes | no</em></strong></dt>
76 <dd>
77 <p>This option is mode specific and controls exporting of CLOB/BLOB or BYTEA data columns during
78 exportdata mode. Possible values: <em>yes or no</em>. Default: <em>no</em>.</p>
79 </dd>
80 <dt><strong><strong>-h, --help</strong></strong></dt>
81 <dd>
82 <p>Print this help message.</p>
83 </dd>
84 <dt><strong><strong>-m, --mode</strong> <em>exportdata | describetable</em></strong></dt>
85 <dd>
86 <p>Data selection criterion from database. Possible values: <em>exportdata or describetable</em>.
87 Default value: <em>exportdata</em>.</p>
88 </dd>
89 <dt><strong><strong>-n, --numoutfilesmode</strong> <em>single | multiple</em></strong></dt>
90 <dd>
91 <p>Number of CSV/TSV output files to generate: combine output into one file or generate
92 a different file for each table in a schema. Possible values: <em>single or multiple</em>. Default:
93 <em>single</em>.</p>
94 <p>In a single output file, data for different tables is separated by a blank line.</p>
95 <p>Single outfile option in <em>exportdata</em> mode is quite useful for exporting data from all tables
96 in specifed schemas to one file which can be used for migrating data to another database
97 or simply provide a backup of data; during <em>describetable</em> mode, it provides a means to
98 collect information about columns of all schema tables which can help in creation of these
99 tables on a different database server.</p>
100 </dd>
101 <dt><strong><strong>-o, --overwrite</strong></strong></dt>
102 <dd>
103 <p>Overwrite existing files.</p>
104 </dd>
105 <dt><strong><strong>--outdelim</strong> <em>comma | tab | semicolon</em></strong></dt>
106 <dd>
107 <p>Output text file delimiter. Possible values: <em>comma, tab, or semicolon</em>.
108 Default value: <em>comma</em></p>
109 </dd>
110 <dt><strong><strong>-q, --quote</strong> <em>yes | no</em></strong></dt>
111 <dd>
112 <p>Put quotes around column values in output text file. Possible values: <em>yes or
113 no</em>. Default value: <em>yes</em>.</p>
114 </dd>
115 <dt><strong><strong>-r, --root</strong> <em>rootname</em></strong></dt>
116 <dd>
117 <p>New file name is generated using the root:&lt;Root&gt;.&lt;Ext&gt; and &lt;Root&gt;&lt;TableName&gt;.&lt;Ext&gt;
118 for <em>single</em> and <em>multiple</em> <strong>-n --numoutfiles</strong> option values. Default file name for
119 <em>single</em> <strong>-n --numoutfiles</strong> option value: &lt;Mode&gt;SchemaTables.&lt;Ext&gt;. Default file
120 names for <em>multiple</em> <strong>-n --numoutfiles</strong> value: &lt;Mode&gt;&lt;SchemaName&gt;&lt;TableName&gt;.&lt;Ext&gt;.
121 Based on <strong>-m --mode</strong> option, <em>Export</em> or <em>Describe</em> &lt;Mode&gt; value is used. The csv and tsv
122 &lt;Ext&gt; values are used for comma/semicolon, and tab delimited text files respectively. This option is
123 ignored for multiple input schema names.</p>
124 </dd>
125 <dt><strong><strong>--replacenullstr</strong> <em>string</em></strong></dt>
126 <dd>
127 <p>Replace NULL or undefined row values with specified value. Default: <em>none</em>.</p>
128 <p>For importing output text files into MySQL database using &quot;load data local infile '&lt;tablename&gt;.tsv'
129 into table &lt;tablename&gt;&quot; command, use <em>--raplacenullstr &quot;NULL&quot;</em> in conjunction with <em>--exportdatalabels no</em>,
130 <em>--quote no</em>, and <em>--outdelim tab</em> options: it'll generate files for direct import into MySQL assuming
131 tables already exists.</p>
132 </dd>
133 <dt><strong><strong>-w --workingdir</strong> <em>dirname</em></strong></dt>
134 <dd>
135 <p>Location of working directory. Default: current directory.</p>
136 </dd>
137 </dl>
138 <p>
139 </p>
140 <h2>EXAMPLES</h2>
141 <p>To export data in all tables from mysql schema on a MySQL server running on a local machine
142 using username/password from DBI_USER and DBI_PASS environmental variables, type:</p>
143 <div class="ExampleBox">
144 % DBSchemaTablesToTextFiles.pl mysql</div>
145 <p>To describe all tables in mysql and test schemas on a MySQL server running on a remote machine
146 using explicit username/password and capturing the ouput into a DescribeTables.csv file, type:</p>
147 <div class="ExampleBox">
148 % DBSchemaTablesToTextFiles.pl --dbdriver mysql --dbuser &lt;name&gt;
149 --dbpassword &lt;pasword&gt; --dbname mysql --dbhost
150 &lt;mysqlhostname.org&gt; -r DescribeTable -m describetable
151 -o mysql test</div>
152 <p>To describe all tables in SCOTT schema in Oracle running on a remote machine using explicit
153 username/password and capturing the ouput into a DescribeAllTable.tsv file, type:</p>
154 <div class="ExampleBox">
155 % DBSchemaTablesToTextFiles.pl --dbdriver Oracle --dbuser &lt;name&gt;
156 --dbpassword &lt;pasword&gt; --dbhost &lt;oraclehostname.com&gt;
157 -r DescribeAllTable -m describetable --outdelim tab --quote no
158 -o SCOTT</div>
159 <p>To export data in all tables in mysql and test schemas on a MySQL server running at a local
160 machine using explicit username/password and capturing the data in TSV file for each table with empty
161 values substitued with NULL and clob/blob data, type:</p>
162 <div class="ExampleBox">
163 % DBSchemaTablesToTextFiles.pl --dbdriver Oracle --dbuser &lt;name&gt;
164 --dbpassword &lt;pasword&gt; -r ExportTables --outdelim tab --quote no
165 --replacenullstr &quot;NULL&quot; -m exportdata --exportlobs no --numoutfiles
166 multiple -o user user_info</div>
167 <p>
168 </p>
169 <h2>AUTHOR</h2>
170 <p><a href="mailto:msud@san.rr.com">Manish Sud</a></p>
171 <p>
172 </p>
173 <h2>SEE ALSO</h2>
174 <p><a href="./DBSQLToTextFiles.html">DBSQLToTextFiles.pl</a>,&nbsp<a href="./DBTablesToTextFiles.html">DBTablesToTextFiles.pl</a>
175 </p>
176 <p>
177 </p>
178 <h2>COPYRIGHT</h2>
179 <p>Copyright (C) 2015 Manish Sud. All rights reserved.</p>
180 <p>This file is part of MayaChemTools.</p>
181 <p>MayaChemTools is free software; you can redistribute it and/or modify it under
182 the terms of the GNU Lesser General Public License as published by the Free
183 Software Foundation; either version 3 of the License, or (at your option)
184 any later version.</p>
185 <p>&nbsp</p><p>&nbsp</p><div class="DocNav">
186 <table width="100%" border=0 cellpadding=0 cellspacing=2>
187 <tr align="left" valign="top"><td width="33%" align="left"><a href="./CalculatePhysicochemicalProperties.html" title="CalculatePhysicochemicalProperties.html">Previous</a>&nbsp;&nbsp;<a href="./index.html" title="Table of Contents">TOC</a>&nbsp;&nbsp;<a href="./DBSQLToTextFiles.html" title="DBSQLToTextFiles.html">Next</a></td><td width="34%" align="middle"><strong>March 29, 2015</strong></td><td width="33%" align="right"><strong>DBSchemaTablesToTextFiles.pl</strong></td></tr>
188 </table>
189 </div>
190 <br />
191 <center>
192 <img src="../../images/h2o2.png">
193 </center>
194 </body>
195 </html>