Set up a interactable interface for data entry with one or may SQL databses. Use an object for configuration or import one from YAML, JSON, or any other format.
CC0-1.0 License
A Shiny application that allows easy SQL data entry for anyone once set up with the configuration.yaml
file or any other object from R.
There are 4 steps in setting up the application with Shiny. Installing ShinySQLBrowser, UIContainer
, includeUITable
, and observeSwitch
provide ease of access wrapers.
If needed you can sill call UITable
directly, but for that you will need to read the R/man files.
devtools::install_github("https://github.com/zekrom-vale/ShinySQLBrowser")
library(ShinySQLBrowser)
UIContainer(tables, opt = NULL)
This function takes a list of tables and optionaly a configuration object for format_default
s and advanced configuration such as HTML building.
It returns a container object containing the generated UITables
.
tables
<TableName>:
tab:
title: <TableName>
[value: <Identifiyer, advnaced config>]
[icon: <Icon of the tab>]
con: <SQL connection>
name: <SQL table name>
id: <HTML ID of table>
[types:
<HTML input/select types>[...]]
opt: <option object>
[rows:
<row name>:
[width: <css width not implemented>]
input: <html input/select override>
<row name>:
[width: <css width>]
input:
[con: <SQL connection>]
table: <SQL Table>
key: <SQL column to use as a key>
val: <SQL column to use as a value>
[...]]
[js: <JS lookup, abvanced config>]
[tbl: <function to modify the table>]
keys: <Primary keys of the table>
[...]
See config.yaml:tables
for an example of the table data
opt
[format_default:
<type>: <JS function>
[...]]
See config.yaml:otp
for an example of the simple options data. For more advanced configuration that is default to generating the HTML, see default.yaml
.
includeUITable(container)
Generates table containers HTML and dependencies.
Note that the table HTML will be generated and desposed on the fly.
Include this in the ui
list of Shiny.
container = UIContainer(tables, opt)
ui = bootstrapPage(
theme = bslib::bs_theme(version = 4),
includeUITable(container)
)
shinyApp(ui = ui)
observeSwitch(session, input, container)
This function observes the switching of tabs and geerates or desposes the table
container = UIContainer(tables, opt)
server = function(input, output, session) {
observeSwitch(session, input, container)
onSessionEnded(function(){
# Recomeended to close your pools on close
poolClose(pool)
})
}
shinyApp(server = server)
See /examples for more examples. I will eventualy publish a sanitized version of the logs data.