MongoDB

    Driver Options

    • MongoDB - Please refer to MongoDB’s website for instructions on how to download and setup their official driver: MongoDB ODBC driver page

    • RStudio Professional Drivers - RStudio Server Pro, RStudio Connect, or Shiny Server Pro users can download and use RStudio Professional Drivers at no additional charge. These drivers include an ODBC connector for Apache Impala. RStudio delivers standards-based, supported, professional ODBC drivers. Use RStudio Professional Drivers when you run R or Shiny with your production systems. See the RStudio Professional Drivers for more information.

    Package Options

    The odbc package, in combination with a driver, provides DBI support and an ODBC connection.

    Connection Settings

    There are settings needed to make a connection:

    • Driver - See the Drivers section for setup information
    • Server - Server path or name
    • Port - Should be set to 27017
    • Database - Name of the database you wish to connect to
    • AuthMechanism - See this article from MongoDB for more information: Authentication Mechanisms
    • UID - The user’s network ID or server local account
    • PWD - The account’s password
    con <- DBI::dbConnect(
          odbc::odbc(),
          Driver        = "[your driver's name]",
          Server        = "[your server's path or name]",
          Port          = 27017,
          Database      = "[your database's name]",
          AuthMechanism = "SCRAM-SHA-1", # <- Example, depends server's auth setup
          UID           = rstudioapi::askForPassword("Database user"),
          PWD           = rstudioapi::askForPassword("Database password")
          )