Package 'sqlstrings'

Title: Map 'SQL' Code to R Lists
Description: Provides a helper function, to bulk read 'SQL' code from separate files and load it into an 'R' list, where the list elements contain the individual statements and queries as strings. This works by annotating the 'SQL' code with a name comment, which also will be the name of the list element.
Authors: Dejan Prvulovic [aut, cre]
Maintainer: Dejan Prvulovic <[email protected]>
License: MIT + file LICENSE
Version: 1.0.0
Built: 2025-03-05 03:16:29 UTC
Source: https://github.com/dejse/sqlstrings

Help Index


Read all files from path and return a list, where the list elements contain the individual 'SQL' statements and queries as strings

Description

Read all files from path and return a list, where the list elements contain the individual 'SQL' statements and queries as strings

Usage

generate_sql_strings(path = "")

Arguments

path

A path to a folder or a file containing 'SQL' code

Value

A list with named elements containing 'SQL' statements as strings

Examples

## prepare example file
p <- fs::path(tempdir(), "test-file-001.sql")
fs::file_create(p)
readr::write_lines("
  -- name: select_count
  select count(*) from tab1;
", p)

## sqlstrings
s <- generate_sql_strings(path = p)
s$select_count