sql_split: Split SQL to Single Statements

Description Usage Arguments Details Value See Also Examples

View source: R/sqlparse_retic.R

Description

Split a string with (one or) several SQL statements into single statements.

Usage

1
sql_split(sql, encoding = NULL)

Arguments

sql

Character string containing (one or) several SQL statements

encoding

Character string specifying the input encoding. Default: NULL (assumes UTF-8 or latin-1)

Details

This function is a wrapper to the sqlparse.split() function from the sqlparse python module, which is a non-validating SQL parser.

Value

Character vector with the single SQL statements.

See Also

sql_format, sql_parse

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  if (reticulate::py_module_available("sqlparse")) {

    library("sqlparseR")

    raw <- "select*from foo; select*from bar;"

    statements <- sql_split(raw)

    print(statements)

  }

Example output

Warning message:
In system2(command = python, args = shQuote(config_script), stdout = TRUE,  :
  running command ''/usr/bin/python3' '/usr/lib/R/site-library/reticulate/config/config.py' 2>/dev/null' had status 126

sqlparseR documentation built on Sept. 20, 2019, 5:05 p.m.