create_sql_script: Create a SQL script, optionally execute the statement if con...

View source: R/pgTools.R

create_sql_scriptR Documentation

Create a SQL script, optionally execute the statement if con is not NULL.

Description

Create a SQL script, optionally execute the statement if con is not NULL.

Usage

create_sql_script(..., path = NULL, con = NULL)

Arguments

...

A string, SQL command to be combined into one document or statement.

path

A string, the file path (include the file name) to save the script.

con

A database connection that can be passed to DBI::dbSendQuery/DBI::dbGetQuery.

Value

A string, SQL commands combined into one document or statement; or the results retrieved by DBI::dbSendQuery after executing the statement.

Examples

create_sql_script(
createSCHEMA("dev"),
sql_80_char_comment(),
createTABLE(name = "sample",
columns = list(col1 = "SERIAL NOT NULL", col2 = "INTEGER", col3 = "TEXT"),
constraints = list(sample_constraint = "UNIQUE(col3)")
))

pgTools documentation built on March 31, 2023, 7:56 p.m.