create_sql_script {pgTools}R 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)")
))

[Package pgTools version 1.0.2 Index]