dwong_smartbear
7 years agoOccasional Contributor
Python - Using ADO and RecordSet in testcomplete scripts
Two questions I have regarding the ADO interface with Python: 1. When I do: rec_set = conn.Execute_("SELECT A, B FROM C WHERE D='E") ... there's no problem, but if I do: rec_set = conn.Exec...
- 7 years ago
Here is an approach I used for something similar. It basically will take a record set and build an array of objects with their properties being the column names / values. It's javascript, but shouldn't be hard to do a similar approach in python.
function recordToObjectArray(rec) { let retVal = []; try { while(!rec.EOF) { let currObj = {}; for(var i = 0; i < rec.Fields.Count; i++) { currObj[rec.Fields.Item(i).Name] = rec.Fields.Item(i).Value; } retVal.push(currObj); rec.MoveNext(); } } catch(err) { Log.Warning("There was an error building object. See additional information", err.message + "\n" + err.stack); } finally { return retVal; } }