Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.7 KiB

import basic.program
import utils.config_tool
import os
class DbFcts():
"""
This interface defines each necessary connection to any kind of database.
The specific technique how to connect to the concrete DBMS has to be implemented in the specific tool.
"""
def __init__(self):
self.comp = None
pass
def setComp(self, comp):
self.comp = comp
def selectTables(self):
""" method to delete rows from a database
statement written in sql """
self.loadDdl()
tdata = {}
for t in self.comp.conf["ddl"]:
tdata[t] = self.selectRows(t)
return tdata
def selectRows(self, statement):
""" method to select rows from a database
statement written in sql """
raise Exception("method is not implemented")
def deleteTables(self):
""" method to delete rows from a database
statement written in sql """
self.loadDdl()
for t in self.comp.conf["ddl"]:
print("zu loeschende Tabelle "+t)
self.deleteRows(t)
def deleteRows(self, table):
""" method to delete rows from a database
statement written in sql """
raise Exception("method is not implemented")
def updateRows(self, statement):
""" method to delete rows from a database
statement written in sql """
raise Exception("method is not implemented")
def getConnector(self):
""" add-on-method to get the connector
this method should only called by the class itself """
raise Exception("method is not implemented")
def insertTables(self, tdata):
""" method to insert rows into a database
statement written in sql """
plainname = basic.componentHandling.getPlainCompname(self.comp.name)
self.loadDdl()
for t in self.comp.conf["ddl"]:
print("einzufuegende Tabelle "+t)
if (t in tdata[plainname]):
self.insertRows(t, tdata[plainname][t]["_data"])
def insertRows(self, rows):
""" method to insert rows into a database
the rows will be interpreted by the ddl of the component
"""
raise Exception("method is not implemented")
def execStatement(self, statement):
""" add-on-method to execute the statement
this method should only called by the class itself """
raise Exception("method is not implemented")
def loadDdl(self):
job = basic.program.Job.getInstance()
if ("ddl" in self.comp.conf):
return
conf = utils.config_tool.getConfig("DATASTRUCTURE", self.comp.name)
self.comp.conf["ddl"] = {}
for k in conf[self.comp.name]:
self.comp.conf["ddl"][k] = conf[self.comp.name][k]
return conf[self.comp.name]
def getWhere(self):
return ""
def getOrder(self):
return ""
def getDbValue(self, fo, value):
if len(value.strip()) == 0 and fo["nullable"] == "y":
return self.getDbNull()
if fo["type"] == "string":
return "'"+value.strip()+"'"
elif fo["type"] == "int":
return value.strip()
elif fo["type"] == "double":
return self.getDbDouble(value)
elif fo["type"] == "float":
return self.getDbFloat(value)
elif fo["type"] == "date":
return self.getDbDate(value)
elif fo["type"] == "time":
return self.getDbTime(value)
def getDbDouble(self, value):
return value
def getDbFloat(self, value):
return value
def getDbDate(self, value):
return value
def getDbTime(self, value):
return value
def getDbNull(self):
return "null"