Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dreamRs/sqlquery
Htmlwidget to write SQL queries
https://github.com/dreamRs/sqlquery
addin htmlwidgets r
Last synced: 27 days ago
JSON representation
Htmlwidget to write SQL queries
- Host: GitHub
- URL: https://github.com/dreamRs/sqlquery
- Owner: dreamRs
- License: other
- Created: 2018-05-05T16:42:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-09T11:27:05.000Z (over 6 years ago)
- Last Synced: 2024-08-04T03:02:55.906Z (4 months ago)
- Topics: addin, htmlwidgets, r
- Language: JavaScript
- Homepage:
- Size: 1.5 MB
- Stars: 31
- Watchers: 4
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-shiny-extensions - sqlquery - HTML widget for writing SQL queries with autocompletion for SQL keywords and table/field names. (UI Components / Editor)
- jimsghstars - dreamRs/sqlquery - Htmlwidget to write SQL queries (JavaScript)
README
# sqlquery
> SQL query editor
[![Travis build status](https://travis-ci.org/dreamRs/sqlquery.svg?branch=master)](https://travis-ci.org/dreamRs/sqlquery)
[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)## Overview
Htmlwidget/Shiny gadget to write SQL queries with autocompletion for SQL keywords and for table names and fields.
There are two addins in the package, in both you can write queries, but :* **Non-interactive mode:** you cannot run queries but you keep control over your R session;
* **Interactive mode:** you can run queries and see first rows of result.
## Installation
You can install from Github:
``` r
source("https://install-github.me/dreamRs/sqlquery")
```## Htmlwidget
Basic usage:
``` r
library(sqlquery)
sql_query(value = "SELECT * FROM mtcars")
```Get autocompletion for tables and fields in a Database:
``` r
library(DBI)
con <- dbConnect(RSQLite::SQLite(), ":memory:")
dbWriteTable(conn = con, name = "mtcars", value = mtcars)sql_query(conn = con)
```
![](img/htmlwidget.png)## Shiny app
Basic usage:
``` r
library(sqlquery)
sql_query_app(value = "SELECT * FROM mtcars")
```With a connection :
``` r
library(DBI)
con <- dbConnect(RSQLite::SQLite(), ":memory:")
dbWriteTable(conn = con, name = "mtcars", value = mtcars)sql_query_app(conn = con)
```![](img/shinyapp.png)
Click button *see results* to display first rows with RStudio's `View` (if app runs in pane viewer) or in a modal (if app runs in dialog viewer or browser).
To change display mode, use:
```r
options("sqlquery.display.mode" = "dialog")
```## Addins
You can launch addins via RStudio addins menu. If you want to use a connection with addins, you can set option `sqlquery.connection` in your `.Rprofile` :
```r
options("sqlquery.connection" = function() {
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
DBI::dbWriteTable(conn = con, name = "mtcars", value = mtcars)
return(con)
})
```This has to be a function returning a connection.
If you want to use a default schema, use:
```r
options("sqlquery.schema" = "myschema")
```