Created
March 4, 2019 16:53
-
-
Save bradlindblad/f1966828de1a3f246336828d84a131bc to your computer and use it in GitHub Desktop.
get_db.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_db <- function(query = "SELECT TOP 10 * FROM datas.dbo.Customers") { | |
#' Pull data from g23 database | |
#' @param query: enter a SQL query; Microsoft SQL syntax please | |
require(odbc) | |
con <- dbConnect(odbc(), | |
Driver = "SQL Server", | |
Server = "datas", | |
Database = "dataserver", | |
UID = "user", | |
PWD = rstudioapi::askForSecret("password"), | |
Port = 6969) | |
z <- odbc::dbGetQuery(con, query) | |
return(z) | |
odbc::dbDisconnect(con) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment