/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Properties | Static Private Attributes
DybPython::dbcmd::MySQLImport Class Reference
Inheritance diagram for DybPython::dbcmd::MySQLImport:
Inheritance graph
[legend]
Collaboration diagram for DybPython::dbcmd::MySQLImport:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __call__
def __str__
def __call__

Properties

 exepath = property( _exepath )
 cmd = property( lambda self:self._cmd % self )
 cmd_nopw = property( lambda self:self._cmd % dict(self, password="***") )

Static Private Attributes

list _exenames = ['mysqlimport','mysqlimport5']
string _cmd = 'time %(exepath)s --no-defaults --local --verbose %(replace_ignore)s --host=%(host)s --user=%(user)s --password=%(password)s --fields-optionally-enclosed-by="\\"" --fields-terminated-by=, --ignore-lines=1 %(xopts)s %(database)s %(paths)s '

Detailed Description

Options ``--replace/--ignore`` has an important caveat regarding ``--local``
that is confusingly not mentioned in some places in the documentation:
 
* http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html
* http://dev.mysql.com/doc/refman/5.0/en/load-data.html

* `--local` : reads input files locally from the client host, otherwise attempts to read from as path on the server
* `--no-defaults` : must be the first option

`replace` and `ignore` options control handling of input rows that duplicate existing rows on unique key values. 

* `--replace` : new rows replace existing rows that have the same unique key value. 
* `--ignore`  : input rows that duplicate an existing row on a unique key value are skipped.

If you do not specify either option, the **behavior depends on whether the LOCAL keyword is specified**. 
* Without LOCAL, an error occurs when a duplicate key value is found, and the rest of the text file is ignored. 
* With LOCAL, the default behavior is the same as if IGNORE is specified; this is because the server has no way to stop transmission of the file in the middle of the operation.

DBI updates only add new entries to Vld and Payload tables, so the default (when using `--local` as we must)
of `--ignore` is OK.  

But LOCALSEQNO/GLOBALSEQNO table which is keyed on TABLENAME and contains the LASTUSEDSEQNO for each DBI pair,
must be imported with '--replace' in order for updates to be propagated in.,

Experiment with dupe key behaviour::

       vi ~/dybaux/catalog/tmp_offline_db/LOCALSEQNO/LOCALSEQNO.csv
       python dbcmd.py
       echo select \* from LOCALSEQNO | mysql tmp_offline_db      ## on the DB server


Bad imports leads to NULLified rows::

    0       0000-00-00 00:00:00     0000-00-00 00:00:00     NULL    NULL    NULL    NULL    NULL    0000-00-00 00:00:00     0000-00-00 00:00:00

Definition at line 111 of file dbcmd.py.


Member Function Documentation

def DybPython::dbcmd::MySQLImport::__call__ (   self,
  csvpaths = [],
  verbose = True,
  replace_ignore = "--ignore",
  xopts = "" 
)

Definition at line 151 of file dbcmd.py.

00152                                                                                         :
00153         self['paths']=' '.join(csvpaths)
00154         self['replace_ignore'] = replace_ignore
00155         self['xopts']=xopts   
00156         return CommandLine.__call__(self, verbose=verbose)
00157 
00158 
00159 
00160 
00161 

def DybPython::dbcmd::CommandLine::__str__ (   self) [inherited]

Definition at line 30 of file dbcmd.py.

00031                      :
00032         return "%s %s " % (self.__class__.__name__, self.cmd_nopw )

def DybPython::dbcmd::CommandLine::__call__ (   self,
  kwa 
) [inherited]

Definition at line 33 of file dbcmd.py.

00034                              :
00035         verbose = kwa.pop('verbose', False)
00036         self.update(kwa)
00037         if verbose:
00038             log.info(self)
00039         else:
00040             log.debug(self)
00041         return os.popen(self.cmd).read()        


Member Data Documentation

list DybPython::dbcmd::MySQLImport::_exenames = ['mysqlimport','mysqlimport5'] [static, private]

Definition at line 149 of file dbcmd.py.

string DybPython::dbcmd::MySQLImport::_cmd = 'time %(exepath)s --no-defaults --local --verbose %(replace_ignore)s --host=%(host)s --user=%(user)s --password=%(password)s --fields-optionally-enclosed-by="\\"" --fields-terminated-by=, --ignore-lines=1 %(xopts)s %(database)s %(paths)s ' [static, private]

Definition at line 150 of file dbcmd.py.


Property Documentation

DybPython::dbcmd::CommandLine::exepath = property( _exepath ) [static, inherited]

Definition at line 18 of file dbcmd.py.

DybPython::dbcmd::CommandLine::cmd = property( lambda self:self._cmd % self ) [static, inherited]

Definition at line 19 of file dbcmd.py.

DybPython::dbcmd::CommandLine::cmd_nopw = property( lambda self:self._cmd % dict(self, password="***") ) [static, inherited]

Definition at line 20 of file dbcmd.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:55:40 for DybPython by doxygen 1.7.4