db_engine: Single wrapper for all database actions

Description Usage Arguments Details

Description

We require only a few simple sql methods. They are 1. Writing an entire dataframe directly to a database as it's own table, 2. Reading the same tables as dataframes, possibly with some modification using SQL statements, 3. Checking to see if a table exists. If a particular table does it exists it's assumed it has all data required.

Usage

1
2
db_engine(action, db = "./data/bbsforecasting.sqlite", sql_query = NULL,
  df = NULL, new_table_name = NULL, table_to_check = NULL)

Arguments

action

Action to perform in db call. Either read, write, or check

db

name of database. A file if using sqlite

sql_query

SQL statement if action is read

df

Dataframe of data if action is write. Will copy the dataframe verbatim to it's own table with name new_table_name

new_table_name

Table name for new data being written

table_to_check

Table name to check if it exists for when action is check

Details

read returns a dataframe write returns nothing check returns boolean


weecology/biodivcast documentation built on May 20, 2019, 1:25 p.m.