connect: connect

Description Usage Arguments Details Value DBMS parameter details Examples

View source: R/DatabaseConnector.R

Description

connect creates a connection to a database server.

Usage

1
2
connect(dbms = "sql server", user, domain, password, server, port, schema, extraSettings)
connect(connectionDetails)

Arguments

dbms

The type of DBMS running on the server. Valid values are

  • "mysql" for MySQL

  • "oracle" for Oracle

  • "postgresql" for PostgreSQL

  • "redshift" for Amazon Redshift

  • "sql server" for Microsoft SQL Server

  • "pdw" for Microsoft Parallel Data Warehouse (PDW)

  • "netezza" for IBM Netezza

user

The user name used to access the server.

domain

For SQL Server only: the Windows domain (optional).

password

The password for that user.

server

The name of the server.

port

(optional) The port on the server to connect to.

schema

(optional) The name of the schema to connect to.

extraSettings

(optional) Additional configuration settings specific to the database provider to configure things as security for SSL. These must follow the format for the JDBC connection for the RDBMS specified in dbms

connectionDetails

An object of class connectionDetails as created by the createConnectionDetails function.

Details

This function creates a connection to a database.

Value

An object that extends DBIConnection in a database-specific manner. This object is used to direct commands to the database engine.

DBMS parameter details

Depending on the DBMS, the function arguments have slightly different interpretations: MySQL:

Oracle:

Microsoft SQL Server:

Microsoft PDW:

Connections where the domain need to be specified are not supported PostgreSQL:

Redshift:

Netezza:

To be able to use Windows authentication for SQL Server (and PDW), you have to install the JDBC driver. Download the .exe from Microsoft and run it, thereby extracting its contents to a folder. In the extracted folder you will find the file sqljdbc_4.0/enu/auth/x64/sqljdbc_auth.dll (64-bits) or sqljdbc_4.0/enu/auth/x86/sqljdbc_auth.dll (32-bits), which needs to be moved to location on the system path, for example to c:/windows/system32. In order to enable Netezza support, place your Netezza jdbc driver at inst/java/nzjdbc.jar in this package.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
conn <- connect(dbms = "mysql",
                server = "localhost",
                user = "root",
                password = "xxx",
                schema = "cdm_v4")
dbGetQuery(conn, "SELECT COUNT(*) FROM person")
dbDisconnect(conn)

conn <- connect(dbms = "sql server", server = "RNDUSRDHIT06.jnj.com", schema = "Vocabulary")
dbGetQuery(conn, "SELECT COUNT(*) FROM concept")
dbDisconnect(conn)

conn <- connect(dbms = "oracle",
                server = "127.0.0.1/xe",
                user = "system",
                password = "xxx",
                schema = "test")
dbGetQuery(conn, "SELECT COUNT(*) FROM test_table")
dbDisconnect(conn)

## End(Not run)

hxia/DatabaseConnector4Impala documentation built on May 17, 2019, 9:15 p.m.