Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/MCodrescu/knackr

R Package for Connecting to Knack Databases
https://github.com/MCodrescu/knackr

knack r

Last synced: 3 months ago
JSON representation

R Package for Connecting to Knack Databases

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# knackr

[![R-CMD-check](https://github.com/MCodrescu/knackr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/MCodrescu/knackr/actions/workflows/R-CMD-check.yaml)

The goal of knackr is to facilitate interaction with Knack Databases using the [Knack](https://www.knack.com/) API. If you have any questions or issues please submit a GitHub issue or contact me at [email protected].

## Installation

You can install the development version of knackr from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("MCodrescu/knackr")
```

## Set Credentials

Before interacting with the database, set your API credentials in the R session.

```{r example}
knackr::set_credentials(
api_id = keyring::key_get("Knack Trial", "api_id"),
api_key = keyring::key_get("Knack Trial", "api_key")
)
```

## List Objects

You can list the objects present in a database by using the `list_objects()` function.

``` {r list-objects}
knackr::list_objects()
```

## List Fields

You can also list the fields present in an object using `list_fields()`.

``` {r list-fields}
knackr::list_fields("mtcars")
```

## Retrieve Records
You can retrieve records from a table using `retrieve_records()`.

```{r retrieve-all}
result <- knackr::retrieve_records("mtcars")

dplyr::glimpse(result)
```

By default, `retrieve_records()` returns the entire object, but you can specify the number of rows retrieved.
```{r}
result <- knackr::retrieve_records("mtcars", n = 5)

dplyr::glimpse(result)
```

If you are not sure how many records you have in a table you can use `n_records()` to determine it.

```{r}
knackr::n_records("mtcars")
```