/sqshr

SQL Server client based on sqsh

Primary LanguageRGNU General Public License v3.0GPL-3.0

sqshr - R package to coonect to Microsoft SQL Server for Linux users

Build Status License: GPL v3

There are some inconveniences when you come to communicate with Microsoft SQL server as a Linux client especially in corporate environment. Due to obscure in security details and corporate infrastructure DBI and odbc often do not work from scratch in Linux. That is why FreeTDS is commonly used (see pymssql for example). Sqsh in Linux is a well-known command-line tool leveraging FreeTDS for communication with Microsoft SQL server. Sqshr is a tiny R tool built on top of Sqsh.

Installation

First install Sqsh in your Linux system using appropriate method for your system. In Debian/Ubuntu it looks like

> sudo apt install sqsh

No additional configuration for Sqsh is required.

Now install sqshr package in R using devtools as it commonly used:

options("download.file.method" = "libcurl")  # avoid rare problems with devtools
library(devtools)
devtools::install_github("omega1x/sqshr")

Usage

The usage of sqshr is very straightforward and implies two steps - (1) creation of connection object and (2) sending the SQL-query:

library(sqshr)
# Create connection object:
conn <- mssql_connection(server = "11.100.104.142", domain = "SUEKCORP",
 user = "user", password = "password")

# Ask for data:
 data <- mssql(conn, "SELECT 200 AS V1, 300 AS V2")
 print(data)

##     V1  V2
## 1: 200 300