Skip to content

Commit

Permalink
add dbFetchArrowChunk() example to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nbenn committed Nov 23, 2023
1 parent 1ba7c51 commit 03993ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
9 changes: 4 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,14 @@ res <- dbSendQueryArrow(con, "SELECT * from swiss WHERE Agriculture < ?")
dbBind(res, 30)
while (!dbHasCompleted(res)) {
ret <- dbFetchArrow(res)
message("fetched ", ret$length, " rows")
}
ret <- dbFetchArrow(res)
ret$length
dbBind(res, 20)
# Chunked fetches
while (!dbHasCompleted(res)) {
ret <- dbFetchArrow(res)
ret <- dbFetchArrowChunk(res)
message("fetched ", ret$length, " rows")
}
Expand Down
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ as well.
``` r
# Queries
dbGetQueryArrow(con, "SELECT * from swiss WHERE Agriculture < 40")
#> [[1]]
#> <nanoarrow_array struct[16]>
#> $ length : int 16
#> $ null_count: int 0
Expand Down Expand Up @@ -164,21 +165,19 @@ res <- dbSendQueryArrow(con, "SELECT * from swiss WHERE Agriculture < ?")

dbBind(res, 30)

while (!dbHasCompleted(res)) {
ret <- dbFetchArrow(res)
message("fetched ", ret$length, " rows")
}
#> fetched 10 rows
#> fetched rows
ret <- dbFetchArrow(res)
ret$length
#> NULL

dbBind(res, 20)

while(!dbHasCompleted(res)) {
ret <- dbFetchArrow(res)
# Chunked fetches
while (!dbHasCompleted(res)) {
ret <- dbFetchArrowChunk(res)
message("fetched ", ret$length, " rows")
}
#> fetched 8 rows
#> fetched rows
#> fetched 0 rows

# Cleanup
dbClearResult(res)
Expand Down

0 comments on commit 03993ba

Please sign in to comment.