CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
python.DBImpl.DBImpl Class Reference
Inheritance diagram for python.DBImpl.DBImpl:

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.

7 
8  def __init__( self , schema):
9  """Input: coral schema handle.
10  """
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.

41 
42  def bulkInsert( self, tableName, tabrowDefDict, bulkinput):
43  """Bulk insert bulkinput=[{}]
44  """
45  try:
46  dataEditor=self.__schema.tableHandle(tableName).dataEditor()
47  insertdata=coral.AttributeList()
48  for (columnname,columntype) in tabrowDefDict.items():
49  insertdata.extend(columnname,columntype)
50 
51  bulkOperation=dataEditor.bulkInsert(insertdata,len(bulkinput))
52  for valuedict in bulkinput:
53  for (columnname,columnvalue) in valuedict.items():
54  insertdata[columnname].setData(columnvalue)
55  bulkOperation.processNextIteration()
56  bulkOperation.flush()
57  del bulkOperation
58  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.

59 
60  def deleteRows( self, tableName, condition, conditionbindDict ):
61  """Delete row(s)
62  """
63  try:
64  tableHandle = self.__schema.tableHandle(tableName)
65  editor = tableHandle.dataEditor()
66  editor.deleteRows( condition, conditionbindDict )
67  except Exception, e:
68  raise Exception, str(e)
def python.DBImpl.DBImpl.dropTable (   self,
  tableName 
)
Drop specified table.

Definition at line 69 of file DBImpl.py.

69 
70  def dropTable( self, tableName ):
71  """Drop specified table.
72  """
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.

11 
12  def existRow( self, tableName, condition, conditionbindDict):
13  """Return true if one row fulfills the selection criteria
14  """
15  try:
16  tableHandle = self.__schema.tableHandle(tableName)
17  query = tableHandle.newQuery()
18  query.setCondition(condition,conditionbindDict)
19  cursor = query.execute()
20  result=False
21  while ( cursor.next() ):
22  result=True
23  cursor.close()
24  del query
25  return result
26  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.

27 
28  def insertOneRow( self, tableName, tabrowDefDict, tabrowValueDict ):
29  """Insert row
30  """
31  try:
32  tableHandle = self.__schema.tableHandle(tableName)
33  editor = tableHandle.dataEditor()
34  inputData = coral.AttributeList()
35  for name,type in tabrowDefDict.items():
36  # print name, type
37  inputData.extend( name, type )
38  inputData[name].setData(tabrowValueDict[name])
39  editor.insertRow( inputData )
40  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.

73 
74  def tableExists( self, tableName ):
75  """Tell whether table exists
76  """
77  try:
78  self.__schema.tableHandle(tableName)
79  return True
80  except coral.Exception, e:
81  return False

Member Data Documentation

python.DBImpl.DBImpl.__schema
private

Definition at line 10 of file DBImpl.py.

Referenced by python.IdGenerator.IdGenerator.createIDTable().