Basically after doing a query I'd like to take the resulting rows and produce a []map[string]interface{}
, but I do not see how to do this with the API since the Rows.Scan()
function needs a specific number of parameters matching the requested number of columns (and possibly the types as well) to correctly obtain the data.
Again, I'd like to generalize this call and take any query and turn it into a []map[string]interface{}
, where the map contains column names mapped to the values for that row.
This is likely very inefficient, and I plan on changing the structure later so that interface{}
is a struct for a single data point.
How would I do this using just the database/sql package, or if necessary the database/sql/driver package?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…