sqltocsv icon indicating copy to clipboard operation
sqltocsv copied to clipboard

can't get row count

Open wizofaus opened this issue 5 years ago • 2 comments

There doesn't seem to be a facility for getting the number of rows converted?

wizofaus avatar Jun 02 '19 22:06 wizofaus

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} 

JaanusM avatar Jun 10 '19 19:06 JaanusM

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.

wizofaus avatar Jun 11 '19 23:06 wizofaus