| 0 | 1 <html> | 
|  | 2 <head> | 
|  | 3 <title>MayaChemTools:Documentation:DBSQLToTextFiles.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="./DBSchemaTablesToTextFiles.html" title="DBSchemaTablesToTextFiles.html">Previous</a>  <a href="./index.html" title="Table of Contents">TOC</a>  <a href="./DBTablesToTextFiles.html" title="DBTablesToTextFiles.html">Next</a></td><td width="34%" align="middle"><strong>DBSQLToTextFiles.pl</strong></td><td width="33%" align="right"><a href="././code/DBSQLToTextFiles.html" title="View source code">Code</a> | <a href="./../pdf/DBSQLToTextFiles.pdf" title="PDF US Letter Size">PDF</a> | <a href="./../pdfgreen/DBSQLToTextFiles.pdf" title="PDF US Letter Size with narrow margins: www.changethemargins.com">PDFGreen</a> | <a href="./../pdfa4/DBSQLToTextFiles.pdf" title="PDF A4 Size">PDFA4</a> | <a href="./../pdfa4green/DBSQLToTextFiles.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>DBSQLToTextFiles.pl - Export data from MySQL, Oracle or PostgreSQL database into CSV/TSV text files</p> | 
|  | 22 <p> | 
|  | 23 </p> | 
|  | 24 <h2>SYNOPSIS</h2> | 
|  | 25 <p>DBSQLToTextFiles.pl SQLFileName(s) | SQLSelectStatement(s)...</p> | 
|  | 26 <p>DBSQLToTextFiles.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> SQLStatement | SQLFile] [<strong>-o, --overwrite</strong>] [<strong>--outdelim</strong> comma | tab | semicolon] | 
|  | 30 [<strong>-q, --quote</strong> yes | no] [<strong>-r, --root</strong> rootname] [<strong>--replacenullstr string</strong>] | 
|  | 31 [<strong>-w --workingdir</strong> dirname] SQLFileName(s)  |  SQLSelectStatement(s)...</p> | 
|  | 32 <p> | 
|  | 33 </p> | 
|  | 34 <h2>DESCRIPTION</h2> | 
|  | 35 <p>Export data from MySQL, Oracle or PostgreSQL database into CSV/TSV text files. Based on <strong>-m --mode</strong> | 
|  | 36 option value, two methods of data selection are availble: in line SQL select statement(s), or | 
|  | 37 SQL file name(s) containing SQL select statement(s). All command line parameters must | 
|  | 38 correspond to similar mode; mixing of parameters for different modes is not supported.</p> | 
|  | 39 <p> | 
|  | 40 </p> | 
|  | 41 <h2>OPTIONS</h2> | 
|  | 42 <dl> | 
|  | 43 <dt><strong><strong>-d, --dbdriver</strong> <em>mysql | Oracle | Postgres or Pg</em></strong></dt> | 
|  | 44 <dd> | 
|  | 45 <p>Database driver name. Possible values: <em>mysql, Oracle, Postgres or Pg</em>. Default: <em>MySQL</em> or value of | 
|  | 46 environment variable DBI_DRIVER. This script has only been tested with MySQL, Oracle | 
|  | 47 and PostgreSQL drivers.</p> | 
|  | 48 </dd> | 
|  | 49 <dt><strong><strong>--dbhost </strong> <em>hostname</em></strong></dt> | 
|  | 50 <dd> | 
|  | 51 <p>Database host name. Default: <em>127.0.0.1</em> for both MySQL, Oracle and PostgreSQL. For remote | 
|  | 52 databases, specify complete remote host domain: <em>dbhostname.org</em> or something | 
|  | 53 like it.</p> | 
|  | 54 </dd> | 
|  | 55 <dt><strong><strong>--dbname</strong> <em>databasename</em></strong></dt> | 
|  | 56 <dd> | 
|  | 57 <p>Database name. Default: mysql for MySQL, postgres for PostgreSQL and none for Oracle. | 
|  | 58 For connecting to local/remote Oracle databases, this value can be left undefined assuming | 
|  | 59 <strong>--dbhost</strong> is correctly specified.</p> | 
|  | 60 </dd> | 
|  | 61 <dt><strong><strong>--dbpassword</strong> <em>password</em></strong></dt> | 
|  | 62 <dd> | 
|  | 63 <p>Database user password. Default: <em>none</em> and value of environment variable DBI_PASS | 
|  | 64 is used for connecting to database.</p> | 
|  | 65 </dd> | 
|  | 66 <dt><strong><strong>--dbusername</strong> <em>username</em></strong></dt> | 
|  | 67 <dd> | 
|  | 68 <p>Database user name. Default: <em>none</em> and value of environment variable DBI_USER is | 
|  | 69 used for connecting to database.</p> | 
|  | 70 </dd> | 
|  | 71 <dt><strong><strong>--exportdatalabels</strong> <em>yes | no</em></strong></dt> | 
|  | 72 <dd> | 
|  | 73 <p>This option is mode specific and controls exporting of column data labels during | 
|  | 74 exportdata mode. Possible values: <em>yes or no</em>. Default: <em>yes</em>.</p> | 
|  | 75 </dd> | 
|  | 76 <dt><strong><strong>--exportlobs</strong> <em>yes | no</em></strong></dt> | 
|  | 77 <dd> | 
|  | 78 <p>This option is mode specific and controls exporting of CLOB/BLOB data columns during | 
|  | 79 exportdata mode. Possible values: <em>yes or no</em>. Default: <em>no</em>.</p> | 
|  | 80 </dd> | 
|  | 81 <dt><strong><strong>-h, --help</strong></strong></dt> | 
|  | 82 <dd> | 
|  | 83 <p>Print this help message.</p> | 
|  | 84 </dd> | 
|  | 85 <dt><strong><strong>-m, --mode</strong> <em>SQLStatement | SQLFile</em></strong></dt> | 
|  | 86 <dd> | 
|  | 87 <p>Data selection criterion from database. Two different command line parameter methods | 
|  | 88 are available: in line SQL statement(s) specification or file name(s) containing SQL select | 
|  | 89 statement(s). This value determines how command line parameters are processed.</p> | 
|  | 90 <p>Possible values: <em>SQLStatement or SQLFile</em>. Default value: <em>SQLStatement</em></p> | 
|  | 91 <p>In SQLFile mode, SQL file contains select statements delimited by <em>;</em>. And the lines starting | 
|  | 92 with <em>#</em> or <em>-</em> are ignored.</p> | 
|  | 93 </dd> | 
|  | 94 <dt><strong><strong>-o, --overwrite</strong></strong></dt> | 
|  | 95 <dd> | 
|  | 96 <p>Overwrite existing files.</p> | 
|  | 97 </dd> | 
|  | 98 <dt><strong><strong>--outdelim</strong> <em>comma | tab | semicolon</em></strong></dt> | 
|  | 99 <dd> | 
|  | 100 <p>Output text file delimiter. Possible values: <em>comma, tab, or semicolon</em> | 
|  | 101 Default value: <em>comma</em>.</p> | 
|  | 102 </dd> | 
|  | 103 <dt><strong><strong>-q, --quote</strong> <em>yes | no</em></strong></dt> | 
|  | 104 <dd> | 
|  | 105 <p>Put quotes around column values in output text file. Possible values: <em>yes or | 
|  | 106 no</em>. Default value: <em>yes</em>.</p> | 
|  | 107 </dd> | 
|  | 108 <dt><strong><strong>-r, --root</strong> <em>rootname</em></strong></dt> | 
|  | 109 <dd> | 
|  | 110 <p>New file name is generated using the root:<Root><No>.<Ext>. Default new file | 
|  | 111 file names: SQLStatement<No>.<Ext>, or <SQLFileName><StatementNo>.<Ext>. | 
|  | 112 The csv and tsv <Ext> values are used for comma/semicolon, and tab delimited | 
|  | 113 text files respectively.This option is ignored for multiple input parameters.</p> | 
|  | 114 </dd> | 
|  | 115 <dt><strong><strong>--replacenullstr</strong> <em>string</em></strong></dt> | 
|  | 116 <dd> | 
|  | 117 <p>Replace NULL or undefined row values with specified value. Default: <em>none</em></p> | 
|  | 118 <p>For importing output text files into MySQL database using "load data local infile '<tablename>.tsv' | 
|  | 119 into table <tablename>" command, use <em>--raplacenullstr "NULL"</em> in conjunction with <em>--exportdatalabels no</em>, | 
|  | 120 <em>--quote no</em>, and <em>--outdelim tab</em> options: it'll generate files for direct import into MySQL assuming | 
|  | 121 tables already exists.</p> | 
|  | 122 </dd> | 
|  | 123 <dt><strong><strong>-w --workingdir</strong> <em>dirname</em></strong></dt> | 
|  | 124 <dd> | 
|  | 125 <p>Location of working directory. Default: current directory.</p> | 
|  | 126 </dd> | 
|  | 127 </dl> | 
|  | 128 <p> | 
|  | 129 </p> | 
|  | 130 <h2>EXAMPLES</h2> | 
|  | 131 <p>To export all data in user_info table from a MySQL server running on a local machine | 
|  | 132 using username/password from DBI_USER and DBI_PASS environmental variables, type:</p> | 
|  | 133 <div class="ExampleBox"> | 
|  | 134     % DBSQLToTextFiles.pl -o "select * from user_info"</div> | 
|  | 135 <p>To describe user table in a MySQL server running on a remote machine using explicit | 
|  | 136 username/password and capturing the output into a UserTable.csv file, type:</p> | 
|  | 137 <div class="ExampleBox"> | 
|  | 138     % DBSQLToTextFiles.pl --dbdriver mysql --dbuser <name> --dbpassword | 
|  | 139       <pasword> --dbname mysql --dbhost <mysqlhostname.org> -r UserTable | 
|  | 140       -m SQLStatement -o "select * from user_info"</div> | 
|  | 141 <p>To describe table all_tables in Oracle running on a remote machine using explicit | 
|  | 142 username/password and capturing the output into a AllTable.tsv file, type:</p> | 
|  | 143 <div class="ExampleBox"> | 
|  | 144     % DBSQLToTextFiles.pl --dbdriver Oracle --dbuser <name> --dbpassword | 
|  | 145       <pasword> --dbhost <oraclehostname.com> -r AllTable -m SQLStatement | 
|  | 146       --outdelim tab --quote no -o "select * from all_tables"</div> | 
|  | 147 <p>To run all SQL statement in a file sample.sql on a local Oracle host and capturing output | 
|  | 148 in a SampleSQL.csv file, type:</p> | 
|  | 149 <div class="ExampleBox"> | 
|  | 150     % DBSQLToTextFiles.pl --dbdriver Oracle --dbuser <name> --dbpassword | 
|  | 151       <pasword> -r SampleSQL -m SQLFile -o sample.sql</div> | 
|  | 152 <p> | 
|  | 153 </p> | 
|  | 154 <h2>AUTHOR</h2> | 
|  | 155 <p><a href="mailto:msud@san.rr.com">Manish Sud</a></p> | 
|  | 156 <p> | 
|  | 157 </p> | 
|  | 158 <h2>SEE ALSO</h2> | 
|  | 159 <p><a href="./DBSchemaTablesToTextFiles.html">DBSchemaTablesToTextFiles.pl</a>, <a href="./DBTablesToTextFiles.html">DBTablesToTextFiles.pl</a> | 
|  | 160 </p> | 
|  | 161 <p> | 
|  | 162 </p> | 
|  | 163 <h2>COPYRIGHT</h2> | 
|  | 164 <p>Copyright (C) 2015 Manish Sud. All rights reserved.</p> | 
|  | 165 <p>This file is part of MayaChemTools.</p> | 
|  | 166 <p>MayaChemTools is free software; you can redistribute it and/or modify it under | 
|  | 167 the terms of the GNU Lesser General Public License as published by the Free | 
|  | 168 Software Foundation; either version 3 of the License, or (at your option) | 
|  | 169 any later version.</p> | 
|  | 170 <p> </p><p> </p><div class="DocNav"> | 
|  | 171 <table width="100%" border=0 cellpadding=0 cellspacing=2> | 
|  | 172 <tr align="left" valign="top"><td width="33%" align="left"><a href="./DBSchemaTablesToTextFiles.html" title="DBSchemaTablesToTextFiles.html">Previous</a>  <a href="./index.html" title="Table of Contents">TOC</a>  <a href="./DBTablesToTextFiles.html" title="DBTablesToTextFiles.html">Next</a></td><td width="34%" align="middle"><strong>March 29, 2015</strong></td><td width="33%" align="right"><strong>DBSQLToTextFiles.pl</strong></td></tr> | 
|  | 173 </table> | 
|  | 174 </div> | 
|  | 175 <br /> | 
|  | 176 <center> | 
|  | 177 <img src="../../images/h2o2.png"> | 
|  | 178 </center> | 
|  | 179 </body> | 
|  | 180 </html> |