Movatterモバイル変換


[0]ホーム

URL:


qryflow

R-CMD-checkCodecov test coverage

Overview

Execute multi-step ‘SQL’ statements using specially formattedcomments that define and control execution.

qryflow lets you definemulti-step SQLworkflows using comment-based tags in your SQL code. These tagstell R how to execute each SQL chunk and what to name the results. Thisallows you to:

Install

You can install the released version ofqryflow fromCRAN with:

install.packages("qryflow")

And the development version from GitHub with:

# install.packages("devtools")devtools::install_github("christian-million/qryflow")

Example

The code below demonstrates the primary use case forqryflow.

Basic Usage:

library(qryflow)# Connection to In-Memory DB with table populated from mtcarscon<-example_db_connect(mtcars)sql<-"-- @exec: drop_cyl_6DROP TABLE IF EXISTS cyl_6;-- @exec: prep_cyl_6CREATE TABLE cyl_6 ASSELECT *FROM mtcarsWHERE cyl = 6;-- @query: df_mtcarsSELECT *FROM mtcars;-- @query: df_cyl_6SELECT *FROM cyl_6;"# Pass tagged SQL to `qryflow`results<-qryflow(sql, con)# Access the results from the chunk named `df_cyl_6`head(results$df_cyl_6)#>    mpg cyl  disp  hp drat    wt  qsec vs am gear carb#> 1 21.0   6 160.0 110 3.90 2.620 16.46  0  1    4    4#> 2 21.0   6 160.0 110 3.90 2.875 17.02  0  1    4    4#> 3 21.4   6 258.0 110 3.08 3.215 19.44  1  0    3    1#> 4 18.1   6 225.0 105 2.76 3.460 20.22  1  0    3    1#> 5 19.2   6 167.6 123 3.92 3.440 18.30  1  0    4    4#> 6 17.8   6 167.6 123 3.92 3.440 18.90  1  0    4    4

The path to a file containing SQL can also be passed:

filepath<-example_sql_path('mtcars.sql')# Pass tagged SQL to `qryflow`results<-qryflow(filepath, con)# Access the results from the chunk named `df_cyl_6`results$df_cyl_6|>head()#>    mpg cyl  disp  hp drat    wt  qsec vs am gear carb#> 1 21.0   6 160.0 110 3.90 2.620 16.46  0  1    4    4#> 2 21.0   6 160.0 110 3.90 2.875 17.02  0  1    4    4#> 3 21.4   6 258.0 110 3.08 3.215 19.44  1  0    3    1#> 4 18.1   6 225.0 105 2.76 3.460 20.22  1  0    3    1#> 5 19.2   6 167.6 123 3.92 3.440 18.30  1  0    4    4#> 6 17.8   6 167.6 123 3.92 3.440 18.90  1  0    4    4

Additional Learning

Consider the following vignettes for a more in depthunderstanding:

Similar Packages

The functionality made available byqryflow exists inother packages. However, the scope and implementation ofqryflow makes it distinct enough to justify a uniquepackage.

I recommend reviewing these other packages to see which works bestfor your needs. If you feel this list is incomplete, please submit anissue:


[8]ページ先頭

©2009-2025 Movatter.jp