Execute PostgreSQL statements.

psql_execute_db(
  sql,
  config_path = getOption("psql.config_path", NULL),
  config_value = getOption("psql.config_value", "default")
)

Arguments

sql

A string of the SQL statement to execute.

config_path

A string of a file path to the yaml configuration file. The default value grabs the file path from the psql.config_path option and uses NULL if no value supplied.

config_value

A string of the name of value. The default value grabs the value from the psql.config_value option and uses "default" if no value is supplied.

Value

A scalar numeric of the number of rows affected by the statement.

Details

The function open and closes its own database connection. You do not need to close the database connection afterwards. This function is a wrapper on DBI::dbExecute().

Examples

if (FALSE) { # \dontrun{
psql_execute_db(
  "CREATE SCHEMA boat_count"
)
psql_execute_db(
  "CREATE TABLE boat_count.input (
  file_name TEXT NOT NULL,
  comment TEXT)"
)
} # }