ATLAS Offline Software
Loading...
Searching...
No Matches
python.utils.AtlRunQueryUtils.DBConnectionController Class Reference
Collaboration diagram for python.utils.AtlRunQueryUtils.DBConnectionController:

Public Member Functions

 __init__ (self)
 GetDBConn (self, schema, db)
 get_auth (self, key)
 GetAtlasRunDBConnection (self)
 GetSFODBConnection (self)
 GetTier0DBConnection (self)
 GetPVSSDBConnection (self)
 CloseAll (self)

Public Attributes

dict openConn = {}
dict pw = {}

Detailed Description

Definition at line 108 of file AtlRunQueryUtils.py.

Constructor & Destructor Documentation

◆ __init__()

python.utils.AtlRunQueryUtils.DBConnectionController.__init__ ( self)

Definition at line 109 of file AtlRunQueryUtils.py.

109 def __init__(self):
110 self.openConn = {}
111 self.pw = {}
112

Member Function Documentation

◆ CloseAll()

python.utils.AtlRunQueryUtils.DBConnectionController.CloseAll ( self)

Definition at line 179 of file AtlRunQueryUtils.py.

179 def CloseAll(self):
180 for (dbname,dbconn) in self.openConn.items():
181 if isinstance(dbconn,cx_Oracle.Connection):
182 dbconn.close()
183 else:
184 dbconn.closeDatabase()
185
186

◆ get_auth()

python.utils.AtlRunQueryUtils.DBConnectionController.get_auth ( self,
key )

Definition at line 134 of file AtlRunQueryUtils.py.

134 def get_auth(self,key):
135 if key not in self.pw:
136 from os import environ as env
137 #lookup = XMLReader(env['CORAL_DBLOOKUP_PATH']+"/dblookup.xml")
138 #for s in lookup.servicelist.logicalservices:
139 # print ("Service",s['name'])
140 # for p in s.services:
141 # print (" name",p['name'])
142 auth = XMLReader(env['CORAL_AUTH_PATH']+"/authentication.xml")
143 for c in auth.connectionlist.connections:
144 if key!=c['name']:
145 continue
146 self.pw[key] = dict([(p['name'],p['value']) for p in c.parameters])
147 break
148 if key not in self.pw:
149 print ("Can not authenticate DB",key)
150 sys.exit(0)
151 return self.pw[key]
152
153

◆ GetAtlasRunDBConnection()

python.utils.AtlRunQueryUtils.DBConnectionController.GetAtlasRunDBConnection ( self)

Definition at line 154 of file AtlRunQueryUtils.py.

154 def GetAtlasRunDBConnection(self):
155 if 'run' not in self.openConn:
156 auth = self.get_auth('oracle://ATLAS_COOLPROD/ATLAS_COOLOFL_TRIGGER')
157 self.openConn['run'] = cx_Oracle.connect("%s/%s@ATLAS_COOLPROD" % (auth['user'],auth['password']))
158 return self.openConn['run']
159

◆ GetDBConn()

python.utils.AtlRunQueryUtils.DBConnectionController.GetDBConn ( self,
schema,
db )
for example schema=COOLONL_TRIGGER', db='CONDBR2

Definition at line 113 of file AtlRunQueryUtils.py.

113 def GetDBConn(self, schema, db):
114 """for example schema=COOLONL_TRIGGER', db='CONDBR2"""
115 if (schema,db) in self.openConn:
116 return self.openConn[(schema,db)]
117 try:
118 if schema=="DEFECTS":
119 #from AthenaCommon.Logging import logging # this is needed because of some problem in DQUtils logger
120 # the logger there, if called first makes the athena logger crash
121 defdb = DQDefects.DefectsDB("COOLOFL_GLOBAL/CONDBR2",tag=db)
122 defdb.closeDatabase = lambda: None
123 self.openConn[(schema,db)] = defdb
124 else:
125 logging=False
126 from CoolConvUtilities.AtlCoolLib import indirectOpen
127 self.openConn[(schema,db)] = indirectOpen("%s/%s"%(schema,db),True, logging)
128 except Exception:
129 import traceback
130 traceback.print_exc()
131 sys.exit(-1)
132 return self.openConn[(schema,db)]
133

◆ GetPVSSDBConnection()

python.utils.AtlRunQueryUtils.DBConnectionController.GetPVSSDBConnection ( self)

Definition at line 173 of file AtlRunQueryUtils.py.

173 def GetPVSSDBConnection(self):
174 if 'pvss' not in self.openConn:
175 auth = self.get_auth('oracle://ATLAS_PVSSPROD/ATLAS_PVSS_READER')
176 self.openConn['pvss'] = cx_Oracle.connect("%s/%s@ATLAS_PVSSPROD" % (auth['user'],auth['password']))
177 return self.openConn['pvss']
178

◆ GetSFODBConnection()

python.utils.AtlRunQueryUtils.DBConnectionController.GetSFODBConnection ( self)

Definition at line 160 of file AtlRunQueryUtils.py.

160 def GetSFODBConnection(self):
161 if 'sfo' not in self.openConn:
162 auth = self.get_auth('oracle://ATLAS_CONFIG/ATLAS_SFO_T0_R')
163 with timer("Opening Connection to ATLAS_SFO_T0_R @ ATLAS_CONFIG"):
164 self.openConn['sfo'] = cx_Oracle.connect("%s/%s@ATLAS_CONFIG" % (auth['user'],auth['password']))
165 return self.openConn['sfo']
166

◆ GetTier0DBConnection()

python.utils.AtlRunQueryUtils.DBConnectionController.GetTier0DBConnection ( self)

Definition at line 167 of file AtlRunQueryUtils.py.

167 def GetTier0DBConnection(self):
168 if 'tier0' not in self.openConn:
169 auth = self.get_auth('oracle://ATLAS_T0/ATLAS_T0')
170 self.openConn['tier0'] = cx_Oracle.connect("%s/%s@ATLAS_T0" % (auth['user'],auth['password']))
171 return self.openConn['tier0']
172

Member Data Documentation

◆ openConn

dict python.utils.AtlRunQueryUtils.DBConnectionController.openConn = {}

Definition at line 110 of file AtlRunQueryUtils.py.

◆ pw

dict python.utils.AtlRunQueryUtils.DBConnectionController.pw = {}

Definition at line 111 of file AtlRunQueryUtils.py.


The documentation for this class was generated from the following file: