library(DBI)
# use duckdb. SQLite does not seem to return rows affected
db = dbConnect(duckdb::duckdb(), dbdir=":memory:")
#db = dbConnect(RSQLite::SQLite(), dbname = "sql.sqlite")

dplyr::copy_to(db, mtcars)
SELECT * FROM mtcars;
Displaying records 1 - 10
mpg cyl disp hp drat wt qsec vs am gear carb
21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4
21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4
22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1
21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1
18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2
18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1
14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4
24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2
22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2
19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4
DROP TABLE IF EXISTS toy;

Number of affected rows: 0

Testing number of rows affected: default output

CREATE TABLE toy AS
SELECT cyl, COUNT(*) AS cnt 
FROM mtcars
GROUP BY cyl
;

Number of affected rows: 3

SELECT * FROM toy;
3 records
cyl cnt
6 7
4 11
8 14
DROP TABLE IF EXISTS toy;

Number of affected rows: 0

Testing number of rows affected: sent to output.var

CREATE TABLE toy AS
SELECT cyl, COUNT(*) AS cnt 
FROM mtcars
GROUP BY cyl
;
rows_affected
## [1] 3
xfun::session_info('knitr')
## R version 4.1.0 (2021-05-18)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.2 LTS
## 
## Locale:
##   LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
##   LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
##   LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
##   LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
## 
## Package version:
##   evaluate_0.14   glue_1.4.2      graphics_4.1.0  grDevices_4.1.0
##   highr_0.9       knitr_1.34.1    magrittr_2.0.1  methods_4.1.0  
##   stats_4.1.0     stringi_1.7.4   stringr_1.4.0   tools_4.1.0    
##   utils_4.1.0     xfun_0.26       yaml_2.2.1
xfun::session_info()
## R version 4.1.0 (2021-05-18)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.2 LTS
## 
## Locale:
##   LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
##   LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
##   LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
##   LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
## 
## Package version:
##   assertthat_0.2.1 base64enc_0.1.3  blob_1.2.2       cli_3.0.1       
##   compiler_4.1.0   crayon_1.4.1     DBI_1.1.1        dbplyr_2.1.1    
##   digest_0.6.27    dplyr_1.0.7      duckdb_0.2.9     ellipsis_0.3.2  
##   evaluate_0.14    fansi_0.5.0      fastmap_1.1.0    generics_0.1.0  
##   glue_1.4.2       graphics_4.1.0   grDevices_4.1.0  highr_0.9       
##   htmltools_0.5.2  jquerylib_0.1.4  jsonlite_1.7.2   knitr_1.34.1    
##   lifecycle_1.0.0  magrittr_2.0.1   methods_4.1.0    pillar_1.6.2    
##   pkgconfig_2.0.3  purrr_0.3.4      R6_2.5.1         rlang_0.4.11    
##   rmarkdown_2.11   stats_4.1.0      stringi_1.7.4    stringr_1.4.0   
##   tibble_3.1.4     tidyselect_1.1.1 tinytex_0.33     tools_4.1.0     
##   utf8_1.2.2       utils_4.1.0      vctrs_0.3.8      withr_2.4.2     
##   xfun_0.26        yaml_2.2.1