read_sql: Parse SQL from file.

Description Usage Arguments Value Author(s) Examples

Description

Parse raw SQL from a file. The main purpose of this function is to get rid of comments which R does not handle very well within the DBI or RODBC packages (or their wrappers (e.g. dplyr)).

Usage

1
read_sql(filename, silent = TRUE)

Arguments

filename

A connection object or a character string.

silent

logical. Warn if a text file is missing a final EOL or if there are embedded nulls. Defaults to TRUE.

Value

A character vector of length the number of lines read.

Author(s)

Joe Mienko, mienkoja@uw.edu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
fname <- tempfile("sql",fileext=".sql")
cat("--query 6
    select a6.column1, --trailing comments
    a6.column2, ---test triple -
    count(a6.column3) as counts, --/* funny comment */
    a6.column3 - a6.column4 ---test single - 
    /*count the number of occurences in table 1; 
    test another comment style
    */
    from data.table a6 /* --1st weirdo comment */
    /* --2nd weirdo comment */
    group by a6.column1\n", file=fname)
read_sql(fname)

pocdata/oliveR documentation built on May 25, 2019, 10:23 a.m.