A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://darwin-eu.github.io/CDMConnector/articles/a04_DBI_connection_examples.html below:

DBI connection examples • CDMConnector

The following connection examples are provided for reference.

Redshift

Redshift is almost identical to Postgres.

SQL Server

Using odbc with SQL Server requires driver setup described here. Note, you’ll likely need to download the ODBC Driver for SQL Server.

con <- DBI::dbConnect(odbc::odbc(),
                      Driver   = "ODBC Driver 18 for SQL Server",
                      Server   = Sys.getenv("CDM5_SQL_SERVER_SERVER"),
                      Database = Sys.getenv("CDM5_SQL_SERVER_CDM_DATABASE"),
                      UID      = Sys.getenv("CDM5_SQL_SERVER_USER"),
                      PWD      = Sys.getenv("CDM5_SQL_SERVER_PASSWORD"),
                      TrustServerCertificate="yes",
                      Port     = 1433)

cdm <- cdmFromCon(con, 
                    cdmSchema = c("tempdb", "dbo"), 
                    writeSchema =  c("ATLAS", "RESULTS"))
DBI::dbDisconnect(con)

The connection to SQL Server can be simplified by configuring a DSN. See here for instructions on how to set up the DSN.If we named it “SQL”, our connection is then simplified to.

Snowflake

We can use the odbc package to connect to snowflake.

con <- DBI::dbConnect(odbc::odbc(),
                          SERVER = Sys.getenv("SNOWFLAKE_SERVER"),
                          UID = Sys.getenv("SNOWFLAKE_USER"),
                          PWD = Sys.getenv("SNOWFLAKE_PASSWORD"),
                          DATABASE = Sys.getenv("SNOWFLAKE_DATABASE"),
                          WAREHOUSE = Sys.getenv("SNOWFLAKE_WAREHOUSE"),
                          DRIVER = Sys.getenv("SNOWFLAKE_DRIVER"))
cdm <- cdmFromCon(con, 
                    cdmSchema =  c("OMOP_SYNTHETIC_DATASET", "CDM53"), 
                    writeSchema =  c("ATLAS", "RESULTS"))
DBI::dbDisconnect(con)

Note, as with SQL server we could set up a DSN to simplify this connection as described here for windows and here for macOS.

Duckdb

Duckdb is an in-process database. We use the duckdb package to connect.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4