sqlDropLast

Description

Removes from Database the last (or the amount specified) entry.

Usage

sqlDropLast(conn, tablename, droplast=1)

Arguments

Argument Description
conn connection handle returned by odbcConnect.
tablename character: a database table name accessible from the connected DSN.
droplast the amount of lines to be removed from the table strating from tail. By default, it removes only 1 line.

Details

Removes from Database the last (or the amount specified) entry.

Value

Invisibly for success (and failures cause errors).

Examples

dta<-odbcConnect("test")
sqlDropLast(dta, "TableTest")

Function

sqlDropLast<-function(conn, tablename, droplast=1){
  table<-sqlFetch(conn, tablename)
  table<-table[1:(nrow(table)-droplast),]
  sqlSave(conn, table, tablename = tablename, safer = F)
}

sqlInitizalize

Description

Loads required libraries and gets the db location.

Usage

sqlInitialize()

Arguments

Argument Description

Details

Loads required libraries and gets the db location from “ruta_database.R” file.

Value

Invisibly for success (and failures cause errors).

Examples

sqlInitialize()

Function

sqlInitialize<-function(){
  library(tidyverse)
  library(RODBC)
  library(openxlsx)
  
  ## Conexión a la base de datos
  source("ruta_database.R", encoding = "UTF-8")
}