ATLAS Offline Software
Loading...
Searching...
No Matches
python.AtlasGeoDBInterface.AtlasGeoDBInterface_SQLite Class Reference
Collaboration diagram for python.AtlasGeoDBInterface.AtlasGeoDBInterface_SQLite:

Public Member Functions

 __init__ (self, geoTag, sqliteDBFullPath, verbose=False)
 ConnectToDB (self)
 GetData (self, tableName)

Public Attributes

 db = None
 bVerbose = verbose
 dbFile = sqliteDBFullPath

Detailed Description

Definition at line 235 of file AtlasGeoDBInterface.py.

Constructor & Destructor Documentation

◆ __init__()

python.AtlasGeoDBInterface.AtlasGeoDBInterface_SQLite.__init__ ( self,
geoTag,
sqliteDBFullPath,
verbose = False )

Definition at line 237 of file AtlasGeoDBInterface.py.

237 def __init__(self,geoTag,sqliteDBFullPath,verbose=False):
238
239 self.db=None
240 self.bVerbose=verbose
241
242 if sqliteDBFullPath:
243 self.dbFile=sqliteDBFullPath
244 else:
245 from AthenaCommon.Utils.unixtools import find_datafile
246 pathlist = os.getenv('CALIBPATH').split(os.pathsep)
247 self.dbFile=find_datafile("Geometry/"+geoTag+".db",pathlist)
248
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

Member Function Documentation

◆ ConnectToDB()

python.AtlasGeoDBInterface.AtlasGeoDBInterface_SQLite.ConnectToDB ( self)

Definition at line 249 of file AtlasGeoDBInterface.py.

249 def ConnectToDB(self):
250
251 try:
252 self.db=sqlite3.connect(self.dbFile)
253 except Exception as e:
254 Logging.log.fatal(f'Failed to open SQLite database {self.dbFile}. {e}')
255 Logging.log.debug(f'Connected to SQLite database {self.dbFile}')
256

◆ GetData()

python.AtlasGeoDBInterface.AtlasGeoDBInterface_SQLite.GetData ( self,
tableName )

Definition at line 257 of file AtlasGeoDBInterface.py.

257 def GetData(self,tableName):
258
259 # Check the existence of the table in the DB
260 cur = self.db.cursor()
261 querystring = "SELECT tbl_name FROM sqlite_master WHERE type='table' AND tbl_name='"+tableName+"'"
262 cur.execute(querystring)
263 checkTable = cur.fetchall()
264 if len(checkTable)==0:
265 Logging.log.info(f'Table {tableName} not found in the SQLite DB. Falling back on the default config')
266 return []
267
268 # Fetch the data
269 cur = self.db.cursor()
270 querystring = "SELECT * FROM "+tableName+" order by "+tableName+"_data_id"
271 cur.execute(querystring)
272 rows = cur.fetchall()
273
274 ncols=len(cur.description)
275 dbData=[]
276 for row in rows:
277 dbDataRow={}
278 for i in range(1,ncols):
279 dbDataRow[cur.description[i][0]]=row[i]
280 Logging.log.debug(f'Fetched Data Row for {tableName}')
281 Logging.log.debug(f'{dbDataRow}')
282 dbData.append(dbDataRow)
283
284 return dbData

Member Data Documentation

◆ bVerbose

python.AtlasGeoDBInterface.AtlasGeoDBInterface_SQLite.bVerbose = verbose

Definition at line 240 of file AtlasGeoDBInterface.py.

◆ db

python.AtlasGeoDBInterface.AtlasGeoDBInterface_SQLite.db = None

Definition at line 239 of file AtlasGeoDBInterface.py.

◆ dbFile

python.AtlasGeoDBInterface.AtlasGeoDBInterface_SQLite.dbFile = sqliteDBFullPath

Definition at line 243 of file AtlasGeoDBInterface.py.


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