Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't get row count #13

Open
wizofaus opened this issue Jun 2, 2019 · 2 comments
Open

can't get row count #13

wizofaus opened this issue Jun 2, 2019 · 2 comments

Comments

@wizofaus
Copy link

wizofaus commented Jun 2, 2019

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

@JaanusM
Copy link

JaanusM commented Jun 10, 2019

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} 

@wizofaus
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants