The Rows.Scan
method takes as many parameters as there are columns in the SQL query.
As the query being executed is SHOW COLUMNS FROM my_table
I cannot omit any column which I don't require (or can I?).
Is there any way to ignore some fields from the query result set which is not required?
Below is my code:
rows, err := db.Query("SHOW COLUMNS FROM " + r.Name)
DieIf(err)
//var field, dataType, ignoreMe1, ignoreMe2, ignoreMe3 string
var field, dataType string
for rows.Next() {
//This Place
// |
// V
if err := rows.Scan(&field, &dataType); err != nil {
DieIf(err)
}
r.Attributes[field] = Attribute{
Name: field,
DataType: dataType,
Constraint: false,
}
}
error:
sql: expected 5 destination arguments in Scan, not 2
scan()
, if you want scan only two values then you can write query likeselect field, type from <tableName>
– Undistinguished