/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::MySQLCommand Class Reference
Inheritance diagram for DybPython::dbcmd::MySQLCommand:
Inheritance graph
[legend]
Collaboration diagram for DybPython::dbcmd::MySQLCommand:
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 = ['mysql','mysql5']
string _cmd = "echo %(sql)s | %(exepath)s --no-defaults %(opts)s --host=%(host)s --user=%(user)s --password=%(password)s %(database)s "
tuple _quote = re.compile('(?=[^-0-9a-zA-Z_./\n])')

Detailed Description

Direct usage of mysql commandline rather than going via mysql-python, useful when the 
tabulated mysql output is needed.

Usage::

    from DybPython import DB
    db = DB("tmp_offline_db")
    print db.mysql("select * from DemoVld where SEQNO in (1,10)", opts="-t" )

   For example::

    In [6]: p db.mysql("select * from DemoVld where SEQNO in (1,16)", opts="-t")
    +-------+---------------------+---------------------+----------+---------+---------+------+-------------+---------------------+---------------------+
    | SEQNO | TIMESTART           | TIMEEND             | SITEMASK | SIMMASK | SUBSITE | TASK | AGGREGATENO | VERSIONDATE         | INSERTDATE          |
    +-------+---------------------+---------------------+----------+---------+---------+------+-------------+---------------------+---------------------+
    |     1 | 2010-01-01 01:00:00 | 2038-01-19 03:14:07 |      127 |       1 |       0 |    0 |          -1 | 2010-01-01 01:00:00 | 2011-08-22 12:14:21 | 
    |    16 | 2010-01-01 04:00:00 | 2038-01-19 03:14:07 |      127 |       1 |       0 |    0 |          -1 | 2010-01-01 04:05:00 | 2011-08-22 12:14:36 | 
    +-------+---------------------+---------------------+----------+---------+---------+------+-------------+---------------------+---------------------+
     
Uses regexp from http://stackoverflow.com/questions/967443/python-module-to-shellquote-unshellquote
in order to protect the input SQL from the shell.  

Definition at line 42 of file dbcmd.py.


Member Function Documentation

def DybPython::dbcmd::MySQLCommand::__call__ (   self,
  sql,
  opts = "" 
)

Definition at line 70 of file dbcmd.py.

00071                                       :
00072         verbose = False
00073         qsql =  self._quote.sub('\\\\', sql).replace('\n',"'\n'") 
00074         self.update( sql=qsql, opts=opts )
00075         return CommandLine.__call__(self, verbose=verbose) 
00076  

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::MySQLCommand::_exenames = ['mysql','mysql5'] [static, private]

Definition at line 66 of file dbcmd.py.

string DybPython::dbcmd::MySQLCommand::_cmd = "echo %(sql)s | %(exepath)s --no-defaults %(opts)s --host=%(host)s --user=%(user)s --password=%(password)s %(database)s " [static, private]

Definition at line 67 of file dbcmd.py.

tuple DybPython::dbcmd::MySQLCommand::_quote = re.compile('(?=[^-0-9a-zA-Z_./\n])') [static, private]

Definition at line 68 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