/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 | Public Attributes
Scraper::dq::db::MyCnf Class Reference

List of all members.

Public Member Functions

def __init__
def section
def mysqldb_pars

Public Attributes

 cfp
 sections
 path
 paths

Detailed Description

Definition at line 157 of file db.py.


Constructor & Destructor Documentation

def Scraper::dq::db::MyCnf::__init__ (   self,
  path = "~/.my.cnf" 
)

Definition at line 158 of file db.py.

00158                                           : 
00159         prime = {}
00160         cfp = ConfigParser(prime)
00161         paths = cfp.read( [os.path.expandvars(os.path.expanduser(p)) for p in path.split(":")] )
00162         log.debug("MyCnf read %s " % repr(paths) )
00163         self.cfp = cfp 
00164         self.sections = cfp.sections() 
00165         self.path = path
00166         self.paths  = paths

Member Function Documentation

def Scraper::dq::db::MyCnf::section (   self,
  sect 
)

Definition at line 167 of file db.py.

00168                            :
        return dict(self.cfp.items(sect))
def Scraper::dq::db::MyCnf::mysqldb_pars (   self,
  sect,
  database = None 
)
Annoyingly mysql-python need these keys

`host` host to connect
`user` user to connect as
`passwd` password to use
`db` database to use

whereas mysql uses slightly different ones

`host`   
`database` 
`user`
`password`

Normally can avoid this annoyance using::

    conn = MySQLdb.connect( read_default_group=sect )   

but when need to impinge `database/db` settings this is not possible.

Definition at line 169 of file db.py.

00170                                                :
00171         """
00172         Annoyingly mysql-python need these keys
00173 
00174         `host` host to connect
00175         `user` user to connect as
00176         `passwd` password to use
00177         `db` database to use
00178 
00179         whereas mysql uses slightly different ones
00180 
00181         `host`   
00182         `database` 
00183         `user`
00184         `password`
00185 
00186         Normally can avoid this annoyance using::
00187 
00188             conn = MySQLdb.connect( read_default_group=sect )   
00189 
00190         but when need to impinge `database/db` settings this is not possible.
00191         """
00192         my2mp = dict(host="host",user="user",password="passwd",database="db", socket="unix_socket")
00193         my = self.section(sect)
00194      
00195         mp = {}
00196         for k in filter(lambda k:k in my2mp,my.keys()):  # key translation, mysql to mysql-python
00197             mp[my2mp[k]] =  my[k]
00198 
00199         if database:
00200             mp["db"] = database 
00201         log.debug("translate mysql config %s into mysql-python config %s " % ( dict(my,password="***") , dict(mp,passwd="***") ))
00202         return mp 
00203 


Member Data Documentation

Definition at line 158 of file db.py.

Definition at line 158 of file db.py.

Definition at line 158 of file db.py.

Definition at line 158 of file db.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:50:03 for Scraper by doxygen 1.7.4