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

In This Package:

desc.py
Go to the documentation of this file.
00001 """
00002 Introspect the table descriptions in the DB ...
00003 for schema checking comparisons against 
00004 what the Spec/Code expects :
00005 this is step zero in handling schema migration.
00006 
00007 
00008 {'Extra': '', 'Default': '0', 'Field': 'SEQNO', 'Key': 'PRI', 'Null': 'NO', 'Type': 'int(11)'}
00009 {'Extra': '', 'Default': '0', 'Field': 'ROW_COUNTER', 'Key': 'PRI', 'Null': 'NO', 'Type': 'int(11)'}
00010 {'Extra': '', 'Default': '', 'Field': 'channelId', 'Key': '', 'Null': 'YES', 'Type': 'int(10) unsigned'}
00011 {'Extra': '', 'Default': '', 'Field': 'status', 'Key': '', 'Null': 'YES', 'Type': 'int(10) unsigned'}
00012 {'Extra': '', 'Default': '', 'Field': 'pedestalHigh', 'Key': '', 'Null': 'YES', 'Type': 'double'}
00013 {'Extra': '', 'Default': '', 'Field': 'sigmaPedestalHigh', 'Key': '', 'Null': 'YES', 'Type': 'double'}
00014 {'Extra': '', 'Default': '', 'Field': 'pedestalLow', 'Key': '', 'Null': 'YES', 'Type': 'double'}
00015 {'Extra': '', 'Default': '', 'Field': 'sigmaPedestalLow', 'Key': '', 'Null': 'YES', 'Type': 'double'}
00016 {'Extra': '', 'Default': '', 'Field': 'thresholdHigh', 'Key': '', 'Null': 'YES', 'Type': 'double'}
00017 {'Extra': '', 'Default': '', 'Field': 'thresholdLow', 'Key': '', 'Null': 'YES', 'Type': 'double'}
00018 
00019 
00020 """
00021 import os
00022 os.environ.setdefault("DBCONF","tmp_offline_db")
00023 from DybDbi import gDbi
00024 
00025 class Result(list):
00026     """
00027     Perform low-level MySQL query against DB number dbno in the cascade
00028     and store result as a list of dicts.
00029 
00030     NB no type conversions are applied, everything stays as strings.  
00031     """
00032     def __init__(self, sql , dbno=0):
00033         list.__init__(self)
00034         stm = gDbi.cascader.CreateStatement(dbno)   
00035         tss = stm.ExecuteQuery(sql)
00036         nf = tss.GetNumFields()
00037         while tss.NextResultRow():
00038             d = dict( [(tss.GetFieldName(n),tss.GetString(n)) for n in range(nf)] )
00039             self.append(d)
00040 
00041     def __str__(self):
00042         return "\n".join( [repr(d) for d in self])
00043 
00044 if __name__=='__main__':
00045 
00046     ## output descriptions of all tables 
00047     tabs = Result("show tables")
00048     for t in map(lambda d:d.values()[0],tabs):
00049         print "\ntable %s " % t 
00050         dsc = Result("describe %s" % t )
00051         print dsc
00052 
00053 
00054 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:57:24 for DybDbi by doxygen 1.7.4