|
@@ -416,7 +416,12 @@ def loadSafely(pars,entries,dryRun=True):
|
|
|
project=pars.get('project','DCIS/Study')
|
|
|
schema=pars.get('schema','demographics')
|
|
|
query=pars.get('query','demographics')
|
|
|
+#add columns from labkey that will be checked to find a match
|
|
|
matchColumns=pars.get('matchColumns',[])
|
|
|
+#whether to insert new entries
|
|
|
+ matchOnly=pars.get('matchOnly',False)
|
|
|
+#print rows to be inserted, debugging feature
|
|
|
+ printRows=pars.get('printRows',False)
|
|
|
|
|
|
updateRows=[]
|
|
|
insertRows=[]
|
|
@@ -437,17 +442,31 @@ def loadSafely(pars,entries,dryRun=True):
|
|
|
updateRows.append(r)
|
|
|
else:
|
|
|
insertRows.append(entry)
|
|
|
-
|
|
|
+
|
|
|
+#update rows
|
|
|
+
|
|
|
n=len(updateRows)
|
|
|
print(f'Updating {n} entries')
|
|
|
|
|
|
- print(updateRows)
|
|
|
+ if printRows:
|
|
|
+ print(updateRows)
|
|
|
|
|
|
if n and not dryRun:
|
|
|
printErr(db.modifyRows('update',project,schema,query,updateRows))
|
|
|
+
|
|
|
+
|
|
|
+#insert rows
|
|
|
+
|
|
|
n=len(insertRows)
|
|
|
print(f'Inserting {n} entries')
|
|
|
- print(insertRows)
|
|
|
+
|
|
|
+ if matchOnly:
|
|
|
+ print('Inserting supressed by matchOnly flag')
|
|
|
+ return
|
|
|
+
|
|
|
+ if printRows:
|
|
|
+ print(insertRows)
|
|
|
+
|
|
|
if n and not dryRun:
|
|
|
printErr(db.modifyRows('insert',project,schema,query,insertRows))
|
|
|
|