Connect to MySQL or Microsoft SQL Server using R



Similar documents
INTRODUCTION: SQL SERVER ACCESS / LOGIN ACCOUNT INFO:

Querying Databases Using the DB Query and JDBC Query Nodes

How to Connect to CDL SQL Server Database via Internet

Release Notes For Versant/ODBC On Windows. Release

CIMHT_006 How to Configure the Database Logger Proficy HMI/SCADA CIMPLICITY

General Tips: Page 1 of 20. By Khaled Elshaer.

Connecting to SQL server

Matisse Installation Guide for MS Windows. 10th Edition

Install MS SQL Server 2012 Express Edition

Jolly Server Getting Started Guide

Installing the MySQL ODBC Connector Windows XP and Windows 7. Roth Technologies, LLC

Windows XP Exchange Client Installation Instructions

Using Microsoft Access Front End to NIMSP MySQL Database

OpenScape Business V2

Tech Note 663 HMI Reports: Creating Alarm Database (WWALMDB) Reports

ODBC Driver Guide. Installation and Configuration. Freezerworks Unlimited Version 6.0

EventSentry Overview. Part I Introduction 1 Part II Setting up SQL 2008 R2 Express 2. Part III Setting up IIS 9. Part IV Installing EventSentry 11

Creating a System DSN for Crystal Reports to Access a Sentinel Server Database. Configuration Guide Version 1.0

ilaw Installation Procedure

Using Microsoft Windows Authentication for Microsoft SQL Server Connections in Data Archive

Migrating helpdesk to a new server

HGC SUPERHUB HOSTED EXCHANGE

Purple Sturgeon Standard VPN Installation Manual for Windows XP

Installing T-HUB on multiple computers

Using ODBC with MDaemon 6.5

SiteCount v2.0 Revised: 10/30/2009

How to Set Up Outlook 2007 and Outlook 2010 for Hosted Microsoft Exchange if the Program is Already Installed

Database Assistant. Once Database Assistant is installed you must login to gain access to the database. Copyright 2009

DataCove. Installation Instructions for Search Plug-in for Microsoft Outlook 2007 & 2010 (All Users)

For paid computer support call

NetSupport DNA Configuration of Microsoft SQL Server Express

ReportBy ODBC Connection setup

Voyager Reporting System (VRS) Installation Guide. Revised 5/09/06

FileMaker 12. ODBC and JDBC Guide

How to Configure Outlook Client for Exchange

Installing SQL Express. For CribMaster 9.2 and Later

NetSupport DNA Configuration of Microsoft SQL Server Express

VPN Overview. The path for wireless VPN users

netld External Authentication Setup Guide

Upgrading from Call Center Reporting to Reporting for Contact Center. BCM Contact Center

HELP DESK MANUAL INSTALLATION GUIDE

Aradial Installation Guide

Quick Instructions Installing on a VPS (Virtual Private Server)

Outlook Profile Setup Guide Exchange 2010 Quick Start and Detailed Instructions

Exchange Outlook Profile/POP/IMAP/SMTP Setup Guide

etoken Enterprise For: SSL SSL with etoken

MSSQL quick start guide

Technical Paper. Defining an ODBC Library in SAS 9.2 Management Console Using Microsoft Windows NT Authentication

FileMaker 13. ODBC and JDBC Guide

Setting Up ALERE with Client/Server Data

Linking Access to SQL Server

PowerSchool Student Information System

Installation Instruction STATISTICA Enterprise Small Business

1. CONFIGURING REMOTE ACCESS TO SQL SERVER EXPRESS

Step by step guide for connecting PC to wired LAN at dormitories of University of Pardubice

Transferring Your Hosting Account

StoreGrid Backup Server With MySQL As Backend Database:

Importing Data from Microsoft Access into LISTSERV Maestro

CounterPoint SQL and Magento ecommerce Interface

Matisse Installation Guide for MS Windows

Connecting LISTSERV to an Existing Database Management System (DBMS)

Outlook 2010 Setup Guide (POP3)

QUANTIFY INSTALLATION GUIDE

How To Install A New Database On A 2008 R2 System With A New Version Of Aql Server 2008 R 2 On A Windows Xp Server 2008 (Windows) R2 (Windows Xp) (Windows 8) (Powerpoint) (Mysql

These notes are for upgrading the Linko Version 9.3 MS Access database to a SQL Express 2008 R2, 64 bit installations:

Installing The SysAidTM Server Locally

STATISTICA VERSION 12 STATISTICA ENTERPRISE SMALL BUSINESS INSTALLATION INSTRUCTIONS

E-Notebook SQL 12.0 Desktop Database Installation Guide. E-Notebook SQL 12.0 Desktop Database Installation Guide

Installing Cobra 4.7

Livezilla How to Install on Shared Hosting By: Jon Manning

Sophos UTM. Remote Access via PPTP Configuring Remote Client

Installing LearningBay Enterprise Part 2

Connecting to the Remote Desktop Service

Installing Crystal Reports Runtime For use with the Human Resource Suite when using Progress version 9

FileMaker 11. ODBC and JDBC Guide

Installation Guide for Microsoft SQL Server 2008 R2 Express. October 2011 (GUIDE 1)

2. Unzip the file using a program that supports long filenames, such as WinZip. Do not use DOS.

4D v1x ODBC Driver INSTALLATION GUIDE

Cloud Services ADM. Agent Deployment Guide

Using Remote Web Workplace Version 1.01

RPM Utility Software. User s Manual

NAS 206 Using NAS with Windows Active Directory

Exchange 2003 Mailboxes

How to connect to ArcSDE spatial database using OpenOffice and Microsoft Office suites

Accessing a Microsoft SQL Server Database from SAS on Microsoft Windows

Using ELM Reports in WhatsUp Gold. This guide provides information about configuring ELM reports in WhatsUp Gold v15.0

Contents. Before You Install Server Installation Configuring Print Audit Secure... 10

Installation / Migration Guide for Windows 2000/2003 Servers

PeopleTools v8.52 Crystal Reports and nvision for Windows 7 Workstation Installation Guide

PaperClip Audit System Installation Guide

SysPatrol - Server Security Monitor

Migrating a Database from Legi for Windows 2.X to MS Access

HOW TO SET UP A DIRECT LINK BETWEEN PRIMAVERA PROJECT MANAGER 5 AND NAVISWORKS. Timo Hartmann t.hartmann@ctw.utwente.nl

MIGRATING TO AVALANCHE 5.0 WITH MS SQL SERVER

How To Create A Microsoft.Com/Sql Server 2000 Instance For Act! (For A Powerpoint) For A Powerline.Com (For Microsoft) Or A Microscientific.Com Or A Windows

ACTi NVR Config Converter User s Manual. Version /06/07

HOW TO DEPLOY AN EJB APLICATION IN WEBLOGIC SERVER 11GR1

educ Office Remove & create new Outlook profile

STATISTICA VERSION 9 STATISTICA ENTERPRISE INSTALLATION INSTRUCTIONS FOR USE WITH TERMINAL SERVER

Transcription:

Connect to MySQL or Microsoft SQL Server using R 1 Introduction Connecting to a MySQL database or Microsoft SQL Server from the R environment can be extremely useful. It allows a research direct access to the data without having to first export it from a database and then import it from a CSV file or entering it directly into R. Database connectivity using R requires a bit more work than just installing a library into R. Depending on the database (e.g. PostgreSQL, MySQL, SQL Server, etc.) it also requires adding some sort of connectivity driver like ODBC. This example will focus on connecting to SQL Server and MySQL and uses Microsoft Windows XP. For MySQL the connector/odbc is available for download at http://dev.mysql.com/downloads/connector/ odbc. For SQL Server the ODBC driver is already available (tested on Windows XP and higher and is available as a native client. After the driver is installed the connection for either database is roughly the same. Once the driver is installed you need to let Windows know the name of the connection. This is done by going to to Control Panel Administrative Tools Data Sources (ODBC). This will bring up a dialog box and will list all of the current data sources. To add a new one click on Add and this will bring up another window that will look similar to Figure 1. Then select the database you wish to connect. 2 MySQL In this example to connect to MySQL one would select MySQL ODBC 5.1 Driver (or current version). Another dialog box as seen in Figure 2 will open. There are several fields that need to be completed. The Data Source Name field is important as it is what will be used in the R code this can be named whatever the researcher would like. The TCP/IP Server will be the IP address or hostname of the database server and is supplied by the database administrator. This c copyright 2012 Statistical-Research.com. 1

can also be localhost if the database is on the same computer that you re running R. User and Password are simply the username and password to access the database. Database is the name of the database on the server you wish to connect. At that point you can test the connection to make sure it works and then click OK. 3 Microsoft SQL Server To use SQL Server one would select SQL Server Native Client 10.0 (or current version). Likewise, another dialog box as seen in Figure 4 will open for a SQL Server connection. This process requires four steps. The first is shown in Figure 4 is to define the Name which can, once again, be anything the research would like. Server is the IP address or hostname of the database. Clicking Next then asks for the Login ID and Password which is, once again, the username and password to access the database and is shown in Figure 3. Clicking Next will then ask for the name of the database to connect as seen in Figure 5. Clicking Next one last time brings up the window as seen in Figure 6. Unless the database has special configuration setting the Finish button can be selected. 4 Using R At this point R can be used to connect to the database using the RODBC library available in R. As far as SQL Server or MySQL the SQL syntax is roughly the same. Once the query is written and the data is pulled from the database R can be used as normal. library(rodbc); channel <- odbcconnect("odbc_name", uid="username", pwd="password"); p <- sqlquery(channel, " SELECT * FROM mytable "); close(channel); 2 c copyright 2012 Statistical-Research.com.

Figure 1: Create New Data Source Dialog Box Figure 2: MySQL Create New Data Source c copyright 2012 Statistical-Research.com. 3

Figure 3: MySQL Confirm Username and Password Figure 4: SQL Server Enter Connection Name and IP Address 4 c copyright 2012 Statistical-Research.com.

Figure 5: SQL Server Select Database Name Figure 6: SQL Server Confirmation c copyright 2012 Statistical-Research.com. 5