sqltocsv
sqltocsv copied to clipboard
can't get row count
There doesn't seem to be a facility for getting the number of rows converted?
Here is what i did. (i did not want to export empty csv)
RowCount, _ := db.Query(sqlQuery)
i := RowCountToExport
for RowCount.Next() {
i++ //Lets count the rows
}
if i == 0 { // If there are no rows, then there is no file :).
println("There are 0 rows, so there will be no file!")
} else {//what ever you want to do}
Iterating all the rows is a potentially very expensive operation, and sqltocsv already does it - I wouldn't want to do it twice just to get a row count. If I really did need it I'd do with the CsvPreProcessorFunc, but it just seems like something that would nice to build into sqltocsv.