I have a SQL string, for example
SELECT * FROM benchmark WHERE xversion = 1.0
And actually, xversion is aliased variable, and self.alias has all the alias info something like
{'CompilationParameters_Family': 'chip_name', 'xversion': 'CompilationParameters_XilinxVersion', 'opt_param': .... 'chip_name': 'CompilationParameters_Family', 'CompilationParameters_Device': 'device'}
Using this alias, I should change the string into as follows.
SELECT * FROM benchmark WHERE CompilationParameters_XilinxVersion = 1.0
For this change, I came up with the following.
def processAliasString(self, sqlString):
components = sqlString.split(' ')
resList = []
for comp in components:
if comp in self.alias:
resList.append(self.alias[comp])
else:
resList.append(comp)
resString = " ".join(resList)
return resString
But, I expect better code not using for loop. What do you think?