Format SQL Queries

A convenient interface for formatting 'SQL' queries directly within 'R'. It acts as a wrapper around the 'sql_format' Rust crate. The package allows you to format 'SQL' code with customizable options, including indentation, case formatting, and more, ensuring your 'SQL' queries are clean, readable, and consistent.


Codecov test coverage R-CMD-check

SQLFormatteR

SQLFormatteR is an R package that provides an easy-to-use wrapper for the sqlformat-rs Rust-based SQL formatter. It allows you to format SQL queries with support for various SQL dialects directly in R.

Features

  • Simple and seamless integration with R.
  • Maintains SQL query readability and consistency.
  • Supports standard SQL formatting options.

Limitations

  • Does not support formatting stored procedures.
  • Only supports the ; delimiter for SQL statements (custom delimiters are not available).

Installation

You can install SQLFormatteR from GitHub using:

# Install devtools if not already installed
if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes")

remotes::install_github("dataupsurge/SQLFormatteR")

Usage

library(SQLFormatteR)

sql_query <- "SELECT * FROM users WHERE age > 18 ORDER BY name;"

formatted_sql <- sql_format(sql_query)

cat(formatted_sql)

Contributing

We welcome contributions! Feel free to submit issues or pull requests to improve the package.

License

This project is licensed under the MIT License. See the LICENSE file for details.

It depends on sqlformat-rs, which is also licensed under MIT.

When distributing this package, you must retain the original MIT license notice.


⭐ If you find this package useful, please consider giving it a star on GitHub!

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("SQLFormatteR")

0.0.3 by Morgan Durand, a month ago


https://dataupsurge.github.io/SQLFormatteR/, https://github.com/dataupsurge/SQLFormatteR


Report a bug at https://github.com/dataupsurge/SQLFormatteR/issues


Browse source code at https://github.com/cran/SQLFormatteR


Authors: Morgan Durand [aut, cre, cph] , Authors of the dependent Rust crates [aut] (see AUTHORS file)


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports assertthat

Suggests covr, docopt, git2r, jsonlite, lintr, optparse, precommit, rextendr, roxygen2, styler, testthat

System requirements: Cargo (Rust's package manager), rustc >= 1.78.0


See at CRAN