# Read database connection data file ConnectfileObject = File.Open(Connectfilename, read, failure) Errormessage = 'Could not open ' + Connectfilename if (ConnectfileObject == failure): File.Logerror(ErrorfileObject, module, Errormessage, error) ConnectfileData = File.Read(ConnectfileObject, empty) if (ConnectfileData != empty): ConnectfileDataList = ConnectfileData.split(',') else: Errormessage = 'No data in ' + Connectfilename File.Logerror(ErrorfileObject, module, Errormessage, error) Errormessage = 'Could not close' + Connectfilename if (File.Close(ConnectfileObject, failure) == failure): File.Logerror(ErrorfileObject, module, Errormessage, error) # Progress update File.Logerror(ErrorfileObject, module, 'Read database connection data', info) # Open database connection. DbObject = Db.Connect(ConnectfileDataList[0], ConnectfileDataList[1], ConnectfileDataList[2], ConnectfileDataList[3], invalid) Errormessage = 'Could not connect to database' if (DbObject == invalid): File.Logerror(ErrorfileObject, module, Errormessage, error) # Prepare a database cursor object. DbCursor = Db.Initcursor(DbObject, invalid) Errormessage = 'Unable to create database cursor'
File.Logerror(ErrorfileObject,module,'Started',info) # Read database connection data file ConnectfileObject = File.Open(Connectfilename,read,failure) Errormessage = 'Could not open ' + Connectfilename if ( ConnectfileObject == failure ) : File.Logerror(ErrorfileObject,module,Errormessage,error) ConnectfileData = File.Read(ConnectfileObject,empty) if ( ConnectfileData != empty ) : ConnectfileDataList = ConnectfileData.split(',') else: Errormessage = 'No data in ' + Connectfilename File.Logerror(ErrorfileObject,module,Errormessage,error) Errormessage = 'Could not close' + Connectfilename if ( File.Close(ConnectfileObject,failure) == failure ) : File.Logerror(ErrorfileObject,module,Errormessage,error) # Progress update File.Logerror(ErrorfileObject,module,'Read database connection data',info) # Open database connection. DbObject = Db.Connect(ConnectfileDataList[0],ConnectfileDataList[1],ConnectfileDataList[2],ConnectfileDataList[3],invalid) Errormessage = 'Could not connect to database' if ( DbObject == invalid ) : File.Logerror(ErrorfileObject,module,Errormessage,error) # Prepare a database cursor object. DbCursor = Db.Initcursor(DbObject,invalid) Errormessage = 'Unable to create database cursor' if ( DbCursor == invalid ) : File.Logerror(ErrorfileObject,module,Errormessage,error) # Progress update
# Read database connection data file ConnectfileObject = File.Open(Connectfilename, read, failure) Errormessage = 'Could not open ' + Connectfilename if (ConnectfileObject == failure): File.Logerror(ErrorfileObject, module, Errormessage, error) ConnectfileData = File.Read(ConnectfileObject, empty) if (ConnectfileData != empty): ConnectfileDataList = ConnectfileData.split(',') else: Errormessage = 'No data in ' + Connectfilename File.Logerror(ErrorfileObject, module, Errormessage, error) Errormessage = 'Could not close' + Connectfilename if (File.Close(ConnectfileObject, failure) == failure): File.Logerror(ErrorfileObject, module, Errormessage, error) # Progress update File.Logerror(ErrorfileObject, module, 'Read database connection data', info) # Read SQL data file SQLfileObject = File.Open(SQLfilename, read, failure) Errormessage = 'Could not open ' + SQLfilename if (SQLfileObject == failure): File.Logerror(ErrorfileObject, module, Errormessage, error) SQLfileData = File.Read(SQLfileObject, empty) Errormessage = 'No data in ' + SQLfilename if (SQLfileData != empty): SQLfileDataList = SQLfileData.split(';\n')
Errormessage = 'Reading queries run file ' + Queriesfilename File.Logerror(ErrorfileObject, module, Errormessage, info) QueriesfileObject = File.Open(Queriesfilename, read, failure) Errormessage = 'Could not open ' + Queriesfilename if (QueriesfileObject == failure): File.Logerror(ErrorfileObject, module, Errormessage, error) QueriesfileData = File.Read(QueriesfileObject, empty) Errormessage = 'No data in ' + Queriesfilename if (QueriesfileData != empty): QueriesfileDataLines = QueriesfileData.split(';\n') else: File.Logerror(ErrorfileObject, module, Errormessage, error) if (File.Close(QueriesfileObject, failure) == failure): print('Could not close %s' % Queriesfilename) # Progress message Errormessage = 'Removing old report files' File.Logerror(ErrorfileObject, module, Errormessage, info) # Remove old report files. with os.scandir(Metricsdir) as files: for file in files: if file.is_file: os.remove(file.path) Errormessage = 'File %s has been removed' % file.path File.Logerror(ErrorfileObject, module, Errormessage, info) # Open export file