Learn R Programming

⚠️There's a newer version (0.2.2) of this package.Take me there.

RSQL

Allows the user to generate and execute select, insert, update and delete 'SQL' queries the underlying database without having to explicitly write 'SQL' code.

ReleaseUsageDevelopment

How to get started

install.packages("RSQL")

How to get started (Development version)

Install the R package using the following commands on the R console:

devtools::install_github("rOpenStats/RSQL", build_opts = NULL)
library(RSQL)

A simple example

To get started execute the following commands:

# 0.  Load libraries
library(RSQL)

# 1.  RSQL
db.name <- getMtcarsdbPath()
rsql <- createRSQL(drv = RSQLite::SQLite(), dbname = db.name)
query_sql <- rsql$gen_select(
    select_fields = c("*"),
    table = "mtcars")

query_sql <- rsql$gen_select(
    select_fields = c("mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs", "am"),
    table = "mtcars",
    where_fields = "gear",
    where_values = 4)
mtcars.observed <- rsql$execute_select(query_sql)

Troubleshooting

Please note that the 'RSQL' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Copy Link

Version

Install

install.packages('RSQL')

Monthly Downloads

265

Version

0.1.3

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Alejandro Baranek

Last Published

May 6th, 2020

Functions in RSQL (0.1.3)

df_verify

Checks that the columns are in the data.frame
remove_quotes

Removes quotes from data.frame columns
sql_execute_update

Executes an update on the database
sql_execute_select

Executes a select on the database
re_quote

This functions remove original quotes and sets validated quotes for corresponding db. If it had no quotes, will only put corresponding quotes symbols
rename_col

renames a column on a data.frame
rm_quotes

Removes quotes from the String
sql_gen_update

Generates an update statement
sql_gen_select

Generates a Select Statement
sql_execute_insert

Executes a statement on the database.
getPackageDir

Get package directory
sql_execute_delete

sql_execute_delete
is_quoted

Determines if the string is quoted or not
%IN%

Operator IN for multiple columns
parse_where_clause

Parses a where clause.
sql_gen_delete

Generates a Delete Statement
sql_retrieve_insert

Retrieves or insert Statement
trim_leading

Returns string w/o leading whitespace
sql_gen_insert

Generates an insert statement.
trim_trailing

Returns string w/o trailing whitespace
sql_retrieve

Retrieves Statement
sql_gen_where_or

Generates a where (or) statement to be used on a SQL statement.
trim

Returns string w/o leading or trailing whitespace
sql_gen_where

Generates a where statement to be used on a SQL statement.
sql_gen_where_list

Generates a where list statement to be used on a SQL statement.
add_quotes

Adds quotes to a string
RSQL.class

The class that provides the SQL functionality.
dequote

Removes the quotes from the string
add_grep_exact_match

add_grep_exact_match
RSQL

rsql
cbind_coerced

TODO: WHAT DOES THIS DO AGAIN?
execute_get_insert

Executes the insert statement
getMtcarsdbPath

getCarsdbPath
createRSQL

Produces a RSQL object