There's a way to know if a query retrieved data from clickhouse database using GOlang?
I have this:
dataRows, err := connect.Query(dbQuery)
if err != nil {
log.Fatal(err)
}
defer dataRows.Close()
I'm wondering if you could do something like:
var rowsRetrieved int = dataRows.RowsCount
Thanks, i'd appreciate your help.
Assuming you only need to know whether there were any rows, you could do:
dataRows, err := connect.Query(dbQuery)
if err != nil {
log.Fatal(err)
}
defer dataRows.Close()
if hasRows := dataRows.Next(); hasRows {
handleRow(dataRows)
for dataRows.Next() {
handleRow(dataRows)
}
} else {
// has no rows
}
func handleRow(rows *sql.Rows) {
// handle the row
}