CMS 3D CMS Logo

Public Member Functions | Private Attributes

python::DBImpl::DBImpl Class Reference

List of all members.

Public Member Functions

def __init__
def bulkInsert
def deleteRows
def dropTable
def existRow
def insertOneRow
def tableExists

Private Attributes

 __schema

Detailed Description

Class wrap up all the database operations.\n

Definition at line 4 of file DBImpl.py.


Constructor & Destructor Documentation

def python::DBImpl::DBImpl::__init__ (   self,
  schema 
)
Input: coral schema handle.

Definition at line 7 of file DBImpl.py.

00008                                 :
00009         """Input: coral schema handle.
00010         """
        self.__schema = schema

Member Function Documentation

def python::DBImpl::DBImpl::bulkInsert (   self,
  tableName,
  tabrowDefDict,
  bulkinput 
)
Bulk insert bulkinput=[{}]

Definition at line 41 of file DBImpl.py.

00042                                                               :
00043         """Bulk insert bulkinput=[{}]
00044         """
00045         try:
00046             dataEditor=self.__schema.tableHandle(tableName).dataEditor()
00047             insertdata=coral.AttributeList()
00048             for (columnname,columntype) in tabrowDefDict.items():
00049                 insertdata.extend(columnname,columntype)
00050                 
00051             bulkOperation=dataEditor.bulkInsert(insertdata,len(bulkinput))
00052             for valuedict in bulkinput:
00053                 for (columnname,columnvalue) in valuedict.items():
00054                     insertdata[columnname].setData(columnvalue)
00055                 bulkOperation.processNextIteration()
00056             bulkOperation.flush()
00057             del bulkOperation
00058         except Exception, e:
            raise Exception, str(e)
def python::DBImpl::DBImpl::deleteRows (   self,
  tableName,
  condition,
  conditionbindDict 
)
Delete row(s)

Definition at line 59 of file DBImpl.py.

00060                                                                    :
00061         """Delete row(s)
00062         """
00063         try:
00064             tableHandle = self.__schema.tableHandle(tableName)
00065             editor = tableHandle.dataEditor()
00066             editor.deleteRows( condition, conditionbindDict )
00067         except Exception, e:
00068             raise Exception, str(e)
        
def python::DBImpl::DBImpl::dropTable (   self,
  tableName 
)
Drop specified table.

Definition at line 69 of file DBImpl.py.

00070                                     :
00071         """Drop specified table.
00072         """
        self.__schema.dropIfExistsTable( tableName )
def python::DBImpl::DBImpl::existRow (   self,
  tableName,
  condition,
  conditionbindDict 
)
Return true if one row fulfills the selection criteria

Definition at line 11 of file DBImpl.py.

00012                                                                 :
00013         """Return true if one row fulfills the selection criteria
00014         """
00015         try:
00016             tableHandle = self.__schema.tableHandle(tableName)
00017             query = tableHandle.newQuery()
00018             query.setCondition(condition,conditionbindDict)
00019             cursor = query.execute()
00020             result=False
00021             while ( cursor.next() ):
00022                 result=True
00023                 cursor.close()
00024             del query
00025             return result
00026         except Exception, e:
            raise Exception, str(e)
def python::DBImpl::DBImpl::insertOneRow (   self,
  tableName,
  tabrowDefDict,
  tabrowValueDict 
)
Insert row 

Definition at line 27 of file DBImpl.py.

00028                                                                        :
00029         """Insert row 
00030         """
00031         try:
00032             tableHandle = self.__schema.tableHandle(tableName)
00033             editor = tableHandle.dataEditor()
00034             inputData = coral.AttributeList()
00035             for name,type in tabrowDefDict.items():
00036                # print name, type
00037                 inputData.extend( name, type )
00038                 inputData[name].setData(tabrowValueDict[name])
00039             editor.insertRow( inputData )
00040         except Exception, e:
            raise Exception, str(e)
def python::DBImpl::DBImpl::tableExists (   self,
  tableName 
)
Tell whether table exists

Definition at line 73 of file DBImpl.py.

00074                                       :
00075         """Tell whether table exists
00076         """
00077         try:
00078             self.__schema.tableHandle(tableName)
00079             return True
00080         except coral.Exception, e:
00081             return False


Member Data Documentation

Definition at line 8 of file DBImpl.py.