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

In This Package:

Classes | Functions | Variables
DybPython::dbsrv Namespace Reference

Classes

class  CSVFormat
class  DB
class  tdict
class  IntoOutfile
class  RemoteIntoOutfile
class  LoadDataLocalInfile
class  PartitionMgr
class  MyCnf

Functions

def _sorted
def attrs_
def timing
def main

Variables

tuple log = logging.getLogger(__name__)
 sorted = _sorted
 MySQLdb = None
 _mysql = None
tuple string_types = attrs_( MySQLdb.constants.FIELD_TYPE , 'VARCHAR DATETIME STRING VAR_STRING' )
dictionary seconds = {}
tuple db = main()

Function Documentation

def DybPython::dbsrv::_sorted (   iterable,
  key = lambda _:_,
  reverse = False 
) [private]
sorted for py23, caution returns lists not tuples

Definition at line 493 of file dbsrv.py.

00493                                   :_, reverse=False):
00494     """  
00495     sorted for py23, caution returns lists not tuples
00496     """ 
00497     temp = [(key(x), x) for x in iterable]
00498     temp.sort()
00499     if reverse:
00500         return [temp[i][1] for i in xrange(len(temp) - 1, -1, -1)] 
00501     return [t[1] for t in temp]
00502 
00503 try:
00504     sorted
def DybPython::dbsrv::attrs_ (   mod,
  names 
)
Access module constants is a version independant way 

Definition at line 521 of file dbsrv.py.

00522                       :
00523     """Access module constants is a version independant way """  
00524     if mod:
00525         return map( lambda _:getattr(mod, _), filter( lambda _:hasattr(mod,_), names.split() ) ) 
00526     else:
        return None 
def DybPython::dbsrv::timing (   func)

Definition at line 531 of file dbsrv.py.

00532                 :
00533     def wrapper(*arg,**kw):
00534         '''source: http://www.daniweb.com/code/snippet368.html'''
00535         t1 = time.time()
00536         res = func(*arg,**kw)
00537         t2 = time.time()
00538         global seconds
00539         seconds[func.func_name] = (t2-t1)
00540         return res 
00541     return wrapper
00542 

def DybPython::dbsrv::main ( )
Need to support logging on py2.3

http://docs.python.org/release/2.3.5/lib/module-logging.html

Definition at line 1650 of file dbsrv.py.

01651           :
01652     """
01653     Need to support logging on py2.3
01654 
01655     http://docs.python.org/release/2.3.5/lib/module-logging.html
01656     """
01657     from optparse import OptionParser
01658     op = OptionParser(usage=__doc__ + "\n" + DB.docs() )
01659     now = datetime.now().strftime("%Y%m%d_%H%M")
01660 
01661     tables = "DqChannel,DqChannelVld,DqChannelStatus,DqChannelStatusVld"   # default tables to backup/propagate
01662 
01663     op.add_option("-l", "--loglevel", default="INFO", help="Choose logging level case insensitively eg INFO,DEBUG,WARN. Default %default " )
01664     op.add_option(      "--logformat", default="%(asctime)s %(name)s %(levelname)-8s %(message)s" , help="Logging format. Default %default " )
01665     op.add_option("-t", "--tables",   default=tables,   help="Comma delimited list of table names to be included in operations. Default %default " )
01666     op.add_option(      "--DB_DROP_CREATE", action="store_true",   help="CAUTION: DROPs and CREATES the database specified in the first argument. Default %default " )
01667     op.add_option("-C", "--noconfirm", action="store_true",   help="Skip interactive confirmation of dangerous operations. Default %default " )
01668     op.add_option("-K", "--nocheck", action="store_true",   help="Skip some slow checking. Default %default " )
01669     op.add_option("-w", "--where",   default=None,   help="Where clause applied to selects on all used tables. Default %default " )
01670     op.add_option(      "--partition",    action="store_true",     help="Use partitioned dumping OR loading, used as an optimization for dealing with very large tables. Default %default " )
01671     op.add_option(      "--partitionrange",  default=None,    help="Partition range in partition indices corresponding to python `range(a,b)` or None for all. Default %default " )
01672     op.add_option(      "--partitionsize",   default="10000",   help="Partition size. Default %default " )
01673     op.add_option(      "--partitionkey",   default="SEQNO,0",     help="Fieldname, field position in CSV on which partition chunking is based. Default %default " )
01674     op.add_option(      "--partitionlast",   default=None,         help="(DEPRECATED now determined automatically) Used to identify the index of the last incomplete partition, in order to skip completeness checks and save into a \"last\" directory. Default %default " )
01675     op.add_option(      "--timestamp",      default=now,  help="Non-partitioned dumps and archives are placed inside date stamped folders, to use a prior one the stamp must be specifed. Default %default " )
01676     op.add_option( "-A","--archiveforce",   action="store_true",     help="Proceed with archiving even if a preexisting archive exists. Default %default " )
01677     op.add_option( "-a","--archive",     action="store_true",     help="Create archives of the backups ready for offbox transfer. Default %default " )
01678     op.add_option( "-x","--extract",     action="store_true",     help="Extracts backup folders from archives. Default %default " )
01679     op.add_option(      "--backupfold",  default="/var/dbbackup/dbsrv",   help="Folder under which backups and archives are kept. Default %default " )
01680     op.add_option( "-T","--transfer",   action="store_true",     help="Must be used together `--archive` option to transfer tarballs to the remote node configured with `--transfercfg`. Default %default " )
01681     op.add_option(      "--transfercfg",   default=os.environ.get('DBSRV_REMOTE_NODE','S:/data'), help="Configure archive transfers with the ssh node name and destination prefix eg \"S:/data\" that comes ahead of the backupfold. Default %default " )
01682     op.add_option( "-s","--home",           default="loopback",     help="Name of .my.cnf section of information_schema DB on server regarded as home. Should normally be \"loopback\". Default %default " )
01683     opts, args = op.parse_args()
01684     level = getattr(logging, opts.loglevel.upper())
01685     try: 
01686         logging.basicConfig(format=opts.logformat,level=level)
01687     except TypeError:
01688         hdlr = logging.StreamHandler()
01689         formatter = logging.Formatter(opts.logformat)
01690         hdlr.setFormatter(formatter)
01691         log.addHandler(hdlr)
01692         log.setLevel(level)
01693     pass
01694     assert len(args)>1, "need 2 or more arguments %s " % repr(args)
01695 
01696     log.info("sys.version_info %s " % repr(sys.version_info)) 
01697     log.info("got %s args : %s " % (len(args), repr(args))) 
01698 
01699     if opts.transfer:
01700         sshenv()   # pick up ssh environment for use from spartan environments such as the cron commandline  
01701 
01702     home = DB(opts.home, opts=opts)
01703  
01704     arg = args[0]
01705     if arg.find(",") > -1:
01706         log.debug("comma delimited argument %s " % arg )
01707         names = arg.split(",")
01708     elif arg.find("\\") > -1 or arg.find("\*") > -1:
01709         log.debug("regexp argument %s " % arg )
01710         ptn = re.compile(arg)
01711         names = filter(lambda dbname:ptn.match(dbname), home.databases)
01712     else:
01713         log.debug("plain single DB argument %s " % arg )
01714         names = [arg]
01715     pass
01716     log.debug("arg %s names %s " % ( arg, repr(names)))
01717     for name in names: 
01718         if opts.DB_DROP_CREATE:    
01719             home.database_drop_create(name)
01720         pass
01721         db = DB(name, opts=opts, home=home)
01722         db.dispatch( *args[1:] ) 


Variable Documentation

tuple DybPython::dbsrv::log = logging.getLogger(__name__)

Definition at line 485 of file dbsrv.py.

Definition at line 506 of file dbsrv.py.

Definition at line 513 of file dbsrv.py.

Definition at line 518 of file dbsrv.py.

tuple DybPython::dbsrv::string_types = attrs_( MySQLdb.constants.FIELD_TYPE , 'VARCHAR DATETIME STRING VAR_STRING' )

Definition at line 527 of file dbsrv.py.

dictionary DybPython::dbsrv::seconds = {}

Definition at line 530 of file dbsrv.py.

tuple DybPython::dbsrv::db = main()

Definition at line 1724 of file dbsrv.py.

| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

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