O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using RODBC

To use the RODBC package to connect to the database, follow these steps:

  1. Load the RODBC library, and create a connection object:
> library(RODBC) 
> con <- odbcConnect("order_dsn", uid="user", pwd="pwd") 
  1. Save the order object into a table in the database:
> sqlSave(con,order, "orders",append=FALSE) 
  1. Get all orders from the database table:
> custData <- sqlQuery(con, "select * from orders") 
  1. Close the connection object:
> close(con) 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required