Closed sarats closed 2 years ago
def searchUpdate(db, field, fname):
# Test using something like LIMIT 2
# myset = db.execute("select expid, JSON_SEARCH(data, 'one', '" + field + "') from xml_inputs where name = '" + fname + "' and JSON_SEARCH(data, 'one', '" + field + "') is not NULL LIMIT 2").fetchall()
myset = db.execute("select expid, JSON_SEARCH(data, 'one', '" + field + "') from xml_inputs where name = '" + fname + "' and JSON_SEARCH(data, 'one', '" + field + "') is not NULL ").fetchall()
count = 0
for i in myset:
eid = i[0]
# print (eid)
pos = i[1]
# print (pos)
reqfield = pos.partition('@')[0] + '@value"'
# print (reqfield)
value = db.execute("select JSON_VALUE(data, " + reqfield + ") from xml_inputs where name = '" + fname + "' and expid = " + str(eid)).fetchall()[0][0]
# print(value)
if value is not None:
count = count + 1
print(value)
# set fieldname as lowercase (e.g., COMPILER -> compiler)
db.execute("update e3smexp set " + field.lower() + " = '" + value + "' where expid = " + str(eid) + " and " + field + " is NULL")
print (count)
return(0)
if __name__ == "__main__":
# if sys.argv[1]:
# filename = sys.argv[1]
# mydburl = initDatabase()
# mydb = create_engine(mydburl, echo=True)
mydb = create_engine(mydburl, echo=False)
searchUpdate(mydb, 'COMPILER', 'env_build.xml')
searchUpdate(mydb, 'MPILIB', 'env_build.xml')
exit(0)
env_build.xml has these variables. Parse and add to e3smexp.
Also need to think if threaded build is enabled and record that.