view mayachemtools/docs/scripts/html/DBSchemaTablesToTextFiles.html @ 2:dfff2614510e draft

Deleted selected files
author deepakjadmin
date Wed, 20 Jan 2016 12:15:15 -0500
parents 73ae111cf86f
children
line wrap: on
line source

<html>
<head>
<title>MayaChemTools:Documentation:DBSchemaTablesToTextFiles.pl</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<link rel="stylesheet" type="text/css" href="../../css/MayaChemTools.css">
</head>
<body leftmargin="20" rightmargin="20" topmargin="10" bottommargin="10">
<br/>
<center>
<a href="http://www.mayachemtools.org" title="MayaChemTools Home"><img src="../../images/MayaChemToolsLogo.gif" border="0" alt="MayaChemTools"></a>
</center>
<br/>
<div class="DocNav">
<table width="100%" border=0 cellpadding=0 cellspacing=2>
<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>
</table>
</div>
<p>
</p>
<h2>NAME</h2>
<p>DBSchemaTablesToTextFiles.pl - Export table data from database SchemaName(s) into CSV/TSV text files</p>
<p>
</p>
<h2>SYNOPSIS</h2>
<p>DBSchemaTablesToTextFiles.pl SchemaName(s)...</p>
<p>DBSchemaTablesToTextFiles.pl [<strong>-d, --dbdriver</strong> mysql | Oracle| Postgres or Pg] [<strong>--dbhost </strong> hostname]
[<strong>--dbname</strong> databasename] [<strong>--dbpassword</strong> password] [<strong>--dbusername</strong> username]
[<strong>--exportdatalabels</strong> yes | no] [<strong>--exportlobs</strong> yes | no] [<strong>-h, --help</strong>]
[<strong>-m, --mode</strong> exportdata | describetable] [<strong>-n, --numoutfilesmode</strong> single | multiple]
[<strong>-o, --overwrite</strong>] [<strong>--outdelim</strong> comma | tab | semicolon]
[<strong>-q, --quote</strong> yes | no] [<strong>-r, --root</strong> rootname] [<strong>--replacenullstr string</strong>]
[<strong>-w --workingdir</strong> dirname] SchemaName(s)...</p>
<p>
</p>
<h2>DESCRIPTION</h2>
<p>Export table data from database SchemaName(s) into CSV/TSV text files. Use <strong>-n --numoutfiles</strong>
option to control the number of text files generated for a database schema.</p>
<p>
</p>
<h2>OPTIONS</h2>
<dl>
<dt><strong><strong>-d, --dbdriver</strong> <em>mysql | Oracle | Postgres or Pg</em></strong></dt>
<dd>
<p>Database driver name. Possible values: <em>mysql, Oracle, Postgres or Pg</em>. Default: <em>MySQL</em> or value of
environment variable DBI_DRIVER. This script has only been tested with MySQL, Oracle
and PostgreSQL drivers.</p>
</dd>
<dt><strong><strong>--dbhost </strong> <em>hostname</em></strong></dt>
<dd>
<p>Database host name. Default: <em>127.0.0.1</em> for both MySQL and Oracle. For remote
databases, specify complete remote host domain: <em>dbhostname.org</em> or something
like it.</p>
</dd>
<dt><strong><strong>--dbname</strong> <em>databasename</em></strong></dt>
<dd>
<p>Database name. Default: mysql for MySQL, postgres for PostgreSQL and none for Oracle.
For connecting to local/remote Oracle databases, this value can be left undefined assuming
<strong>--dbhost</strong> is correctly specified.</p>
</dd>
<dt><strong><strong>--dbpassword</strong> <em>password</em></strong></dt>
<dd>
<p>Database user password. Default: <em>none</em> and value of environment variable DBI_PASS
is used for connecting to database.</p>
</dd>
<dt><strong><strong>--dbusername</strong> <em>username</em></strong></dt>
<dd>
<p>Database user name. Default: <em>none</em> and value of environment variable DBI_USER is
used for connecting to database.</p>
</dd>
<dt><strong><strong>--exportdatalabels</strong> <em>yes | no</em></strong></dt>
<dd>
<p>This option is mode specific and controls exporting of column data labels during
exportdata mode. Possible values: <em>yes or no</em>. Default: <em>yes</em>.</p>
</dd>
<dt><strong><strong>--exportlobs</strong> <em>yes | no</em></strong></dt>
<dd>
<p>This option is mode specific and controls exporting of CLOB/BLOB or BYTEA data columns during
exportdata mode. Possible values: <em>yes or no</em>. Default: <em>no</em>.</p>
</dd>
<dt><strong><strong>-h, --help</strong></strong></dt>
<dd>
<p>Print this help message.</p>
</dd>
<dt><strong><strong>-m, --mode</strong> <em>exportdata | describetable</em></strong></dt>
<dd>
<p>Data selection criterion from database. Possible values: <em>exportdata or describetable</em>.
Default value: <em>exportdata</em>.</p>
</dd>
<dt><strong><strong>-n, --numoutfilesmode</strong> <em>single | multiple</em></strong></dt>
<dd>
<p>Number of CSV/TSV output files to generate: combine output into one file or generate
a different file for each table in a schema. Possible values: <em>single or multiple</em>. Default:
<em>single</em>.</p>
<p>In a single output file, data for different tables is separated by a blank line.</p>
<p>Single outfile option in <em>exportdata</em> mode is quite useful for exporting data from all tables
in specifed schemas to one file which can be used for migrating data to another database
or simply provide a backup of data; during <em>describetable</em> mode, it provides a means to
collect information about columns of all schema tables which can help in creation of these
tables on a different database server.</p>
</dd>
<dt><strong><strong>-o, --overwrite</strong></strong></dt>
<dd>
<p>Overwrite existing files.</p>
</dd>
<dt><strong><strong>--outdelim</strong> <em>comma | tab | semicolon</em></strong></dt>
<dd>
<p>Output text file delimiter. Possible values: <em>comma, tab, or semicolon</em>.
Default value: <em>comma</em></p>
</dd>
<dt><strong><strong>-q, --quote</strong> <em>yes | no</em></strong></dt>
<dd>
<p>Put quotes around column values in output text file. Possible values: <em>yes or
no</em>. Default value: <em>yes</em>.</p>
</dd>
<dt><strong><strong>-r, --root</strong> <em>rootname</em></strong></dt>
<dd>
<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;
for <em>single</em> and <em>multiple</em> <strong>-n --numoutfiles</strong> option values. Default file name for
<em>single</em> <strong>-n --numoutfiles</strong> option value: &lt;Mode&gt;SchemaTables.&lt;Ext&gt;. Default file
names for <em>multiple</em> <strong>-n --numoutfiles</strong> value: &lt;Mode&gt;&lt;SchemaName&gt;&lt;TableName&gt;.&lt;Ext&gt;.
Based on <strong>-m --mode</strong> option, <em>Export</em> or <em>Describe</em> &lt;Mode&gt; value is used. The csv and tsv
&lt;Ext&gt; values are used for comma/semicolon, and tab delimited text files respectively. This option is
ignored for multiple input schema names.</p>
</dd>
<dt><strong><strong>--replacenullstr</strong> <em>string</em></strong></dt>
<dd>
<p>Replace NULL or undefined row values with specified value. Default: <em>none</em>.</p>
<p>For importing output text files into MySQL database using &quot;load data local infile '&lt;tablename&gt;.tsv'
into table &lt;tablename&gt;&quot; command, use <em>--raplacenullstr &quot;NULL&quot;</em> in conjunction with <em>--exportdatalabels no</em>,
<em>--quote no</em>, and <em>--outdelim tab</em> options: it'll generate files for direct import into MySQL assuming
tables already exists.</p>
</dd>
<dt><strong><strong>-w --workingdir</strong> <em>dirname</em></strong></dt>
<dd>
<p>Location of working directory. Default: current directory.</p>
</dd>
</dl>
<p>
</p>
<h2>EXAMPLES</h2>
<p>To export data in all tables from mysql schema on a MySQL server running on a local machine
using username/password from DBI_USER and DBI_PASS environmental variables, type:</p>
<div class="ExampleBox">
    % DBSchemaTablesToTextFiles.pl mysql</div>
<p>To describe all tables in mysql and test schemas on a MySQL server running on a remote machine
using explicit username/password and capturing the ouput into a DescribeTables.csv file, type:</p>
<div class="ExampleBox">
    % DBSchemaTablesToTextFiles.pl --dbdriver mysql --dbuser &lt;name&gt;
      --dbpassword &lt;pasword&gt; --dbname mysql --dbhost
      &lt;mysqlhostname.org&gt; -r DescribeTable -m describetable
      -o mysql test</div>
<p>To describe all tables in SCOTT schema in Oracle running on a remote machine using explicit
username/password and capturing the ouput into a DescribeAllTable.tsv file, type:</p>
<div class="ExampleBox">
    % DBSchemaTablesToTextFiles.pl --dbdriver Oracle --dbuser &lt;name&gt;
      --dbpassword &lt;pasword&gt; --dbhost &lt;oraclehostname.com&gt;
      -r DescribeAllTable -m describetable --outdelim tab --quote no
      -o SCOTT</div>
<p>To export data in all tables in mysql and test schemas on a MySQL server running at a local
machine using explicit username/password and capturing the data in TSV file for each table with empty
values substitued with NULL and clob/blob data, type:</p>
<div class="ExampleBox">
    % DBSchemaTablesToTextFiles.pl --dbdriver Oracle --dbuser &lt;name&gt;
      --dbpassword &lt;pasword&gt; -r ExportTables --outdelim tab --quote no
      --replacenullstr &quot;NULL&quot; -m exportdata --exportlobs no  --numoutfiles
      multiple -o user user_info</div>
<p>
</p>
<h2>AUTHOR</h2>
<p><a href="mailto:msud@san.rr.com">Manish Sud</a></p>
<p>
</p>
<h2>SEE ALSO</h2>
<p><a href="./DBSQLToTextFiles.html">DBSQLToTextFiles.pl</a>,&nbsp<a href="./DBTablesToTextFiles.html">DBTablesToTextFiles.pl</a>
</p>
<p>
</p>
<h2>COPYRIGHT</h2>
<p>Copyright (C) 2015 Manish Sud. All rights reserved.</p>
<p>This file is part of MayaChemTools.</p>
<p>MayaChemTools is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option)
any later version.</p>
<p>&nbsp</p><p>&nbsp</p><div class="DocNav">
<table width="100%" border=0 cellpadding=0 cellspacing=2>
<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>
</table>
</div>
<br />
<center>
<img src="../../images/h2o2.png">
</center>
</body>
</html>