Learn R Programming

pgTools (version 1.0.2)

Functions for Generating PostgreSQL Statements/Scripts

Description

Create PostgreSQL statements/scripts from R, optionally executing the SQL statements. Common SQL operations are included, although not every configurable option is available at this time. SQL output is intended to be compliant with PostgreSQL syntax specifications. PostgreSQL documentation is available here .

Copy Link

Version

Install

install.packages('pgTools')

Monthly Downloads

286

Version

1.0.2

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Timothy Conwell

Last Published

March 24th, 2023

Functions in pgTools (1.0.2)

TRUNCATE

Generate a PostgreSQL TRUNCATE statement, optionally execute the statement if con is not NULL.
DELETE

Generate a PostgreSQL DELETE statement, optionally execute the statement if con is not NULL.
connect

Connect to a local database with local credentials using DBI/odbc.
callPROCEDURE

Generate a PostgreSQL statement to execute a procedure, optionally execute the statement if con is not NULL.
createSCHEMA

Generate a PostgreSQL CREATE SCHEMA statement, optionally execute the statement if con is not NULL.
createTABLE

Generate a PostgreSQL CREATE TABLE statement, optionally execute the statement if con is not NULL.
createDATABASE

Generate a PostgreSQL CREATE DATABASE statement, optionally execute the statement if con is not NULL.
createFUNCTION

Generate a PostgreSQL CREATE FUNCTION statement, optionally execute the statement if con is not NULL.
createEXTENSION

Generate a PostgreSQL CREATE EXTENSION statement, optionally execute the statement if con is not NULL.
quoteText2

Add single quotes to strings using stringi::stri_join, useful for converting R strings into SQL formatted strings.
vecToArrayStr

Write a PostgreSQL array as a string using ARRAY[] format from a vector.
pg_alterColumnType

Helper command to alter a column's data type via ALTER TABLE.
dropEXTENSION

Generate a PostgreSQL DROP EXTENSION statement, optionally execute the statement if con is not NULL.
dropDATABASE

Generate a PostgreSQL DROP DATABASE statement, optionally execute the statement if con is not NULL.
sqlNameWalk

Convert a column name into a PostgreSQL compatible name.
sql_comment

Add a single line SQL comment.
pg_data_types

PostgreSQL data types
insert_table_chunker

Helper function for INSERT
createPROCEDURE

Generate a PostgreSQL CREATE PROCEDURE statement, optionally execute the statement if con is not NULL.
dropSCHEMA

Generate a PostgreSQL DROP SCHEMA statement, optionally execute the statement if con is not NULL.
pg_addColumn

Helper command to add a column via ALTER TABLE.
dropTRIGGER

Generate a PostgreSQL DROP TRIGGER statement, optionally execute the statement if con is not NULL.
dropTABLE

Generate a PostgreSQL DROP TABLE statement, optionally execute the statement if con is not NULL.
createTRIGGER

Generate a PostgreSQL CREATE TRIGGER statement, optionally execute the statement if con is not NULL.
dropFUNCTION

Generate a PostgreSQL DROP FUNCTION statement, optionally execute the statement if con is not NULL.
create_sql_script

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

Write a PostgreSQL array as a string using format from a vector.
pg_renameTable

Helper command to rename a table via ALTER TABLE.
insert_batch_chunker

Helper function for INSERT
querySELECT

Generate a PostgreSQL select statement, optionally execute the statement if con is not NULL.
sql_80_char_comment

Add a 80 char SQL comment, intended to be used for visual breaks in documents.
sqlTypeWalk

Get the PostgreSQL data type for a given R data type.
pg_renameColumn

Helper command to rename a column via ALTER TABLE.
pg_dropColumn

Helper command to drop a column via ALTER TABLE.
dropPROCEDURE

Generate a PostgreSQL DROP PROCEDURE statement, optionally execute the statement if con is not NULL.
callFUNCTION

Generate a PostgreSQL statement to execute a function, optionally execute the statement if con is not NULL.
arrayStrToVec

Write a PostgreSQL array as a string from a vector.
INSERT

Generate a PostgreSQL INSERT statement, optionally execute the statement if con is not NULL.
UPDATE

Generate a PostgreSQL UPDATE statement, optionally execute the statement if con is not NULL.
alterDATABASE

Generate a PostgreSQL ALTER DATABASE statement, optionally execute the statement if con is not NULL.
COPY

Generate a PostgreSQL COPY command, optionally execute the statement if con is not NULL.
alterTABLE

Generate a PostgreSQL ALTER TABLE statement, optionally execute the statement if con is not NULL.
alterSCHEMA

Generate a PostgreSQL ALTER SCHEMA statement, optionally execute the statement if con is not NULL.