MongoDB ODBC driver Getting Started Guide

Contents

Installing the MongoDB ODBC driver

  1. Download the MongoDB ODBC driver for your Windows platform.
  2. Install and license the MongoDB ODBC driver on the machine where your client application is installed.

    For example, if you want to analyse MongoDB data in Excel, install the MongoDB ODBC driver on the machine where Excel is installed.

    To do this, execute the file distribution that you downloaded in the previous step, and follow the onscreen instructions.

    The install program starts the Easysoft License Manager, because you cannot use your Easysoft product until a license is obtained.

    The following types of license are available:

    • Free time-limited trial license, which gives you free and unrestricted use of the product for a limited period (usually 14 days).
    • Full license if you have purchased the product. On purchasing the product, you are given an authorization code, which you use to obtain a license.
  3. In Easysoft License Manager, enter your details.

    Complete the Name, E-Mail Address, and Company fields.

    The E-Mail Address must be the same as the address used to register and download from the Easysoft web site or you will be unable to obtain trial licenses.

  4. Choose Request License.

    You're asked for a license type.

  5. Do one of the following:
    • For a trial license, choose Time Limited Trial and then choose Next.

      The License Manager asks what software you are licensing. Select your product from the drop-down list and then choose Next.

    • If you have obtained an authorization code for a purchased license, select Non-expiring License and then choose Next.

      The License Manager requests your authorization code.

      Enter the authorization code and then choose Next.

  6. The License Manager displays a summary of the information you entered and allows you to choose the method of applying for your license.
  7. Do one of the following:
    • Choose On-line Request if your machine is connected to the internet and can make outgoing connections to port 8884.

      The License Manager then sends a request to the Easysoft license server to activate your license key automatically. This is the quickest method and results in your details being entered immediately into our support database.

    • The remaining three options (Email Request, Print Request, and View Request) are all ways to obtain a license if your machine is off-line (does not have a connection to the internet).

      Each of these methods involves providing Easysoft with information including your machine number (a number unique to your machine) and then waiting to receive your license key.

      Instead of emailing your details to Easysoft, you can enter them directly at the Easysoft web site and your license key will be emailed to you automatically.

      To use this method, choose View Request, and then visit:

      In the licensing page, enter your machine number (and authorization code for a purchased license), choose Submit and your license key will be emailed to you.

      When you receive the license key, you can activate it either by double-clicking the email attachment or by choosing Enter License on the License Manager main screen and pasting the license key into the dialog box.

  8. Choose Finish to exit the License Manager.

    The installation is complete.

Configuring an ODBC data source

Before you can use the MongoDB ODBC driver to connect your application to MongoDB, you need to configure an ODBC data source. An ODBC data source stores the connection details for the target database (in this case, MongoDB) and the ODBC driver that is required to connect to it (in this case, the MongoDB ODBC driver).

You configure ODBC data sources in ODBC Data Source Administrator, which is included with Windows.

There are two versions of ODBC Data Source Administrator. The version of ODBC Data Source Administrator that you need to run depends on whether the application you want to connect to MongoDB is 32-bit or 64-bit. Refer to the following table to find out the application's architecture.

Application Architecture
Access There is both a 32-bit and a 64-bit version of Access. To find out which version of Access you have, start Access, and then start Windows Task Manager. In Task Manager, choose the Processes tab. Search for MSACCESS.EXE in the list. If the process name is MSACCESS.EXE *32, Microsoft Access is 32-bit. If the process name is MSACCESS.EXE, Microsoft Access is 64-bit.
Excel There is both a 32-bit and a 64-bit version of Excel. To find out which version of Excel you have, start Excel, and then start Windows Task Manager. In Task Manager, choose the Processes tab. Search for Excel.exe in the list. If this process name is followed by *32, your version of Excel is 32-bit. Otherwise, your version of Excel is 64-bit.
Oracle The Oracle component that interacts with the MySQL ODBC driver is called DG4ODBC. There is both a 32-bit and a 64-bit version of DG4ODBC. To find out which version of DG4ODBC you have, start the Windows Task Manager and choose the Processes tab. In a Command Prompt window, type dg4odbc --help. In the Windows Task Manager, search for the DG4ODBC process. If the Image Name is dg4odbc.exe *32 DG4ODBC is 32-bit. If the Image Name is dg4odbc.exe DG4ODBC is 64-bit. Press CTRL+C in the Command Prompt window, when you have used the Windows Task Manager to find out DG4ODBC's architecture.
SQL Server There is both a 32-bit and a 64-bit version of SQL Server. To find out which version of SQL Server you have, connect to your SQL Server instance, and then run this SQL statement:
select SERVERPROPERTY('edition')
GoodData CloudConnect Designer is a 64-bit application.
MicroStrategy MicroStrategy is a 32-bit application.
Oracle Business Intelligence Enterprise Edition (OBIEE) The OBIEE component that interacts with the ODBC driver is called the Oracle BI Administration Tool. The Oracle BI Administration Tool is 64-bit.
PHPRunner PHPRunner is a 32-bit application.
QlikView QlikView is a 32-bit application if the Force 32 Bit check box is selected. Otherwise, QlikView is a 64-bit application.
SAP BusinessObjects Central Management Server is a 64-bit application. Business View Manager, Information Design Tool and Web Intelligence Rich Client are 32-bit applications.
SAP Crystal Reports Crystal Reports is a 32-bit application.
Tableau Tableau is a 32-bit application.
TIBCO Spotfire TIBCO Spotfire is a 64-bit application.

If you have a 64-bit application, you need to run the 64-bit version of ODBC Data Source Administrator. To do this, open Administrative Tools in Control Panel, and then open Data Sources (ODBC). (On Windows Server 2003 and earlier, the Control Panel applet that launches ODBC Data Source Administrator is labelled Data Sources. On Windows 8 and later, the Control Panel applet is labelled ODBC Data Sources (64-bit).)

If you have a 32-bit application, you need to run 32-bit version of ODBC Data Source Administrator. To do this, in the Windows Run dialog box, enter:

%windir%\syswow64\odbcad32.exe

Use ODBC Data Source Administrator to create a MongoDB ODBC driver data source:

  1. Choose the System DSN tab, and then choose Add.
  2. In the Create New Data Source dialog box, choose Easysoft ODBC-MongoDB Driver, and then choose Finish.
  3. Complete these fields Easysoft ODBC-MongoDB Driver DSN Setup dialog box:
    Setting Value
    DSN MongoDB
    Description Easysoft MongoDB ODBC driver
    Server The name or IP address of the host where your MongoDB instance is running.
    User Name If you need to supply a user name to access your MongoDB database, enter it here.
    Password The password for your MongoDB user name.
    Ignore Auth Some applications (for example MicroStrategy, Oracle Heterogeneous Services (DG4ODBC), Oracle BI Administration Tool) always pass a user name and password on the ODBC connection string, regardless of whether they are required by the target database. If your application behaves in this way and your MongoDB database does not require a user name and a password, enable this setting.
  4. Use the Test button to verify that you can successfully connect to your MongoDB database.

Connecting your application to MongoDB

Connecting Excel to MongoDB

Follow these steps to return data from MongoDB to Microsoft Excel by using the Data Connection Wizard:

  1. Do one of the following:
    • For Excel 2007 and later, on the Data tab, in the From Other Sources group, choose Data Connection Wizard.
    • For Excel 2003 and earlier, on the Data menu, choose Import External Data, and then choose Import Data.
  2. For Excel 2003 and earlier, in the Select Data Source dialog box, choose New Source. For Excel 2007 and later, skip this step.
  3. In the Data Connection Wizard, choose ODBC DSN from the list, and then choose Next.
  4. Choose your MongoDB ODBC driver data source from the list, and then choose Next.
  5. Choose the table that contains the data you want to retrieve, and then choose Next.
  6. Name and describe your new data connection file, and then choose Finish.
  7. In the Select Data Source dialog box, open your new data connection file.
  8. In the Import Data dialog box choose the destination cell and worksheet for the data, and then choose OK to return your data to Excel.

Follow these steps to return data from MongoDB to Microsoft Excel by using Microsoft Query:

  1. Do one of the following:
    • For Excel 2007 and later, on the Data tab, in the From Other Sources group, choose From Microsoft Query.
    • For Excel 2003 and earlier, on the Data menu, choose Import External Data, and then choose New Database Query.

    The New Database Query command uses Microsoft Query to import data. Microsoft Query is an optional feature, which by default is not installed. If you do not have Microsoft Query installed, choosing New Database Query will prompt you to install it. To do this, in Control Panel, choose Programs and Features (or Add or Remove Programs). Choose Microsoft Office (if you installed Excel as part of Office) or Microsoft Excel, and then choose Change. Follow the instructions on screen. Select Choose advanced customization of applications during the Setup wizard if this option is present for your version of Office or Excel. Microsoft Query is located under Office Tools.

    When you have installed Microsoft Query, repeat step 1.

  2. In the Choose Data Source dialog box, choose your MongoDB ODBC driver data source from the list, and then choose OK.
  3. In the Query Wizard, choose the columns that contain the data you want to retrieve, and then click Next.
  4. If you want to return a subset of the data, use the Filter Data screen to filter the results of your query (this is the equivalent of a SQL WHERE clause), and then click Next.
  5. If you want to change the sort order of your data, use the Sort Order screen to sort the results of your query (this is the equivalent of a SQL ORDER BY clause), and then click Next.
  6. Click Finish to return your MongoDB data to Excel.

Connecting GoodData to MongoDB

  1. In GoodData, create a new GoodData project named GDMongoDB.
  2. In CloudConnect Designer, create a new CloudConnect project named CCMongoDB. Choose GDMongoDB as your GoodData working project.
  3. In your CloudConnect project, create a new graph named MongoDBGraph.
  4. In the Outline pane, choose Connections > Create DB Connection.
  5. Complete the Database Connection dialog box.
    Setting Value
    Name MongoDBConnection
    URL jdbc:odbc:dsn_source;

    where dsn_source is the MongoDB ODBC data source that you created on the CloudConnect Designer machine.

    JDBC specific Generic ODBC
  6. Save the connection as MongoDB.cfg and then choose Finish.
  7. Add a new DBInputTable to your graph.
  8. Double-click the DBInputTable.
  9. Complete the Edit component dialog box.
    Property Value
    DB Connection MongoDBConnection
    SQL Query select * from airline
  10. Right-click the DBInputTable, and then choose Extract MetaData. Choose Finish.
  11. In the navigator Pane, right-click your project and choose New > Logical Data Model.
  12. Name your Logical Data Model MongoDBLDM when prompted, and then choose Finish.
  13. Right-click in the mongodbldm.ldm pane, and then choose Create Dataset.
  14. Add one attribute and one fact to the dataset:
    Title Type Datatype
    UNIQUE_CARRIER Attribute Text (128)
    AIRLINE_ID Fact Integer
  15. Right-click the dataset, and then choose Publish model to server.
  16. Choose the target project when prompted.
  17. In the pane for your graph, double-click the GD Dataset Writer.
  18. In the Data set value, choose ..., and then choose your data set whene prompted.
  19. In the field mapping value, choose ..., and then confirm the field mappings.
  20. Add a new GD Dataset Writer to your graph.
  21. Drag a connector from the DBInputTable to the GD Dataset Writer.
  22. Double-click the GD Dataset Writer.
  23. In the Ports tab, choose airline (id:Metadata0) as the Input port.
  24. Run your CloudConnect project to make the MongoDB data available to your GoodData reports.
  25. Log in to your GoodData project.

    The MongoDB data set is accessible by choosing Manage and then choosing the Data pane.

Connecting MicroStrategy to MongoDB

These instructions show you how to use the MongoDB ODBC driver to connect MicroStrategy Analytics Desktop to MongoDB and provide real time access to your MongoDB data, enabling you to analyse MongoDB data from your MicroStrategy dashboard.

  1. In MicroStrategy Analytics Desktop, choose Import > Data.
  2. In the Select your data source pane, choose Database.
  3. In the Database connections pane, choose the New connection button (+).
  4. In the Database Connection dialog box, choose DSN Connections.
  5. In the DSN list, choose your MongoDB ODBC data source.
  6. Leave the DBMS list set to Generic DBMS.
  7. Enter your MongoDB user name and password in the spaces provided.

    Although these details are already stored in the data source, presumably MicroStrategy appends the user name and password specified here to the connection string it passes to SQLDriverConnect. You therefore need to supply the user name and password again, otherwise the connection will fail.

    If your MongoDB server does not require you to specify a user name and a password, enter some "dummy" values in the MicroStrategy dialog box. Then edit your MongoDB ODBC data source in ODBC Data Source Administrator and select the Ignore Auth check box.

  8. In the Name box, enter "Easysoft MongoDB", and then choose OK.
  9. In the Database connections pane, choose "Easysoft MongoDB".

    MicroStrategy retrieves the available MongoDB tables, and displays them in the Available tables pane.

    Retrieve the MongoDB data that you want by using drag and drop.

  10. Save the data as MongoDB Account Detail when prompted.

    The data can now be used in a MicroStrategy dashboard.

Connecting Oracle to MongoDB

The following instructions show you how to connect Oracle on Windows to MongoDB. For further information about DG4ODBC, refer to our DG4ODBC for Windows tutorial.

  1. Create a DG4ODBC init file. To do this, change to the %ORACLE_HOME%\hs\admin directory. Create a copy of the file initdg4odbc.ora. Name the new file initmongodb.ora.

    Note In these instructions, replace %ORACLE_HOME% with the location of your Oracle HOME directory. For example, C:\oraclexe\app\oracle\product\11.2.0\server.

  2. Ensure these parameters and values are present in your init file:
    HS_FDS_CONNECT_INFO = my_mongodb_odbc_dsn

    Replace my_mongodb_odbc_dsn with the name of a MongoDB ODBC driver data source that connects to the target MongoDB server. For example:

    HS_FDS_CONNECT_INFO = "32-bit MongoDB System"

    If your MongoDB server does not require you to supply a user name and a password, include IgnoreAuth=Yes in the HS_FDS_CONNECT_INFO parameter value. For example:

    HS_FDS_CONNECT_INFO = "32-bit MongoDB System;IgnoreAuth=Yes"
  3. Comment out the line that enables DG4ODBC tracing. For example:
    #HS_FDS_TRACE_LEVEL = <trace_level>
  4. Add an entry to %ORACLE_HOME%\network\admin\listener.ora that creates a SID_NAME for DG4ODBC. For example:
    SID_LIST_LISTENER =
     (SID_LIST =
       (SID_DESC=
         (SID_NAME=mongodb)
         (ORACLE_HOME=%ORACLE_HOME%)
         (PROGRAM=dg4odbc)
       )
     )
  5. Add a DG4ODBC entry to %ORACLE_HOME%\network\admin\tnsnames.ora that specifies the SID_NAME created in the previous step. For example:
    MONGODB =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = oracle_host)(PORT = 1521))
        (CONNECT_DATA =
          (SID = mongodb)
        )
        (HS = OK)
      )

    Replace oracle_host with the host name of your Oracle machine.

  6. Start (or restart) the Oracle Listener:
    cd %ORACLE_HOME%\bin
    lsnrctl stop
    lsnrctl start
  7. Connect to your Oracle database in SQL*Plus.
  8. In SQL*Plus, create a database link for the target MongoDB server. For example:
    CREATE PUBLIC DATABASE LINK mongodblink CONNECT TO
    "my_mongodb_user" IDENTIFIED by "my_mongodb_password" USING 'mongodb';

    Or, if your MongoDB server does not require you to supply a user name and a password:

    CREATE PUBLIC DATABASE LINK mongodblink USING 'mongodb';
  9. To prevent Oracle from capitalising object names, enclose object names in your SQL statements with quotation marks ("). For example:
    select * from "airline"@mongodblink where "_id" = '53e0e5d672342e8bb94c5e84';

    If you do this, Oracle will preserve the specified capitalisation for object names.

Notes

Connecting MongoDB to Oracle Business Intelligence Enterprise Edition (OBIEE)

These instructions show you how to import MongoDB data into an Oracle BI metadata repository. You can then reorganise the imported data into a business model for presentation to users who request business intelligence information by using the Oracle BI user interfaces.

  1. Start the Oracle BI Administration Tool (admintool.exe).
  2. On the File menu, choose New Repository.

    The Create New Repository dialog box is displayed.

  3. In the Repository Information screen, in the Name box, enter MongoDB.
  4. Choose the Browse button that is next to the Location box. Choose OK when prompted.
  5. In the Repository Password box, enter a password for the repository. Reenter the password in the space provided.
  6. Choose Next.
  7. In the Select Data Source screen, choose your MongoDB ODBC data source, and then choose Next.
  8. In the Select Metadata Types screen, accept the default metadata types and click Next.
  9. In the Select Metadata Objects screen, in the Find box, enter airline and press Return. Choose the Import selected button.
  10. Choose Finish to open the repository.
  11. In the Physical pane, right-click your data source, and then choose Expand All.
  12. Select Connection Pool and press Return.

    The Connection Pool dialog box is displayed.

  13. If your MongoDB server requires you to supply a user name and password, enter these details in the spaces provided.

    –Or–

    If your MongoDB server does not require you to specify a user name and a password, enter some "dummy" values in the Connection Pool dialog box. Then edit your MongoDB ODBC data source in ODBC Data Source Administrator and select the Ignore Auth check box.

  14. Right-click airline, and then choose View Data.

    Viewing data, if successful, tells you that your connection is configured correctly.

Further information

Connecting PHPRunner to MongoDB

PHPRunner enables you to rapidly create a PHP-based web front end for your MongoDB data.

  1. In PHPRunner, create a new project named MongoDB.

    The Database type screen is displayed.

  2. In the Other section, choose ODBC Data Source, and then choose Next.

    The ODBC DSN screen is displayed.

  3. In the Available ODBC DSNs list, choose your MongoDB ODBC data source, and then choose Next.

    The Datasource tables screen is displayed.

  4. In the list of tables, clear db.system.indexes, select dbo.airline, and then choose Next.

    The Datasource tables screen is displayed.

  5. In the SQL tab, change line 2 of the default query to from _id to '_id' AS ID. The new query will look like this:
    SELECT
            '_id' AS ID,
            UNIQUE_CARRIER,
            AIRLINE_ID,
            CARRIER,
            TAIL_NUM,
            FL_NUM
    FROM dbo.airline

    Choose Next.

    The Choose pages screen is displayed.

  6. Choose Build.
  7. Choose View in browser when prompted.

Connecting QlikView to MongoDB

The following instructions show you how to analyse MongoDB data from your QlikView documents.

  1. In QlikView, open a QlikView document or create a new one.
  2. On the File menu, choose Edit Script.

    The Edit Script dialog box is displayed.

  3. In the Data tab, choose ODBC from the Database list.

    Note The Data tab contains a Force 32 Bit check box. This is provided for ODBC drivers where only a 32-bit version is available. You can leave this check box clear when using the MongoDB ODBC driver. (If Force 32 Bit is selected, you will still be able to use the MongoDB ODBC driver, as the driver distribution includes both a 32-bit and a 64-bit ODBC driver. However, system data sources configured in the 64-bit ODBC Data Source Administrator will not be visible.)

  4. Choose the Connect button.

    The Connect to Data Source dialog box is displayed.

  5. Choose your MongoDB ODBC Data Source from the list and then choose OK.

    If your ODBC Data Source is not listed, choose Show User DSNs.

  6. In the Edit Script dialog box, choose the Select button.

    The Create Select Statement dialog box is displayed.

  7. In the Database Tables list, choose the MongoDB table that contains the data you want to retrieve.
  8. To retrieve a subset of the fields in this table, choose the fields you want in the Fields list. Otherwise, skip this step.
  9. QlikView recommend that the Preceding Load check box is selected. Choose OK.
  10. In the Edit Script dialog box, choose Reload.

    If this is a new document, you will be prompted to save the document at this stage.

  11. If necessary, use the Close button to dismiss the Script Execution Progress message box, when QlikView has finished retrieving the MongoDB data.

    The Sheet Properties dialog box is displayed.

  12. Use either the Add or the Add All button to display the MongoDB fields you want in your QlikView document. Choose OK.

Connecting SAP BusinessObjects to MongoDB

These instructions show you how to publish MongoDB data in a BusinessObjects repository and access that data from a BusinessOnbjects client tool. You need to install the Mongo ODBC driver on both the BusinessObjects Server and client tools machines. You need to configure a Mongo ODBC driver system data source with the same name on both these machines.

64-bit Windows The BusinessObjects Central Management Server is a 64-bit application, and so you need to configure the data source in the 64-bit ODBC Data Source Administrator. The BusinessObjects client tools are 32-bit applications, and so you need to configure the data source in the 32-bit ODBC Data Source Administrator.

  1. On the BusinessObjects Client tools machine, start the Information Design Tool.
  2. On the File menu, choose New, and then choose Project.

    The New Project dialog box is displayed.

  3. Enter MongoDB in the space provided and then choose Finish.
  4. On the Window menu, choose Repository Resources to make the Repository Resources pane visible.
  5. In the Repository Resources pane, choose the + icon, and then choose Insert Session.
  6. Log in to your BusinessObjects Central Management Server when prompted.
  7. Expand the node for the new session, right-click on the Connections folder, and then choose Insert Relational Connection.

    The New Relational Connection dialog box is displayed.

  8. Enter MongoDB in the space provided and then choose Next.
  9. In the database middleware list, expand Generic, expand Generic ODBC3 datasource, choose ODBC Drivers, and then choose Next.

    The New Relational Connection dialog box is displayed.

  10. In the Data Source Name list, choose the MongoDB ODBC data source that you created on the BusinessObjects Central Management Server, and then choose Finish.
  11. In the Repository Resources pane, expand the Connections list, right-click MongoDB and then choose Create Relational Connection Shortcut. Double-click MongoDB when prompted to choose a project.
  12. In the Local Projects pane, right-click MongoDB, choose New and then choose New Data Foundation.

    The New Data Foundation dialog box is displayed.

  13. Enter MongoDB in the Resource Name box, and then choose Next.
  14. Choose Single Source, and then choose Next.
  15. Select MongoDB in the Select Connection list, and then choose Finish.
  16. In the Connection pane, expose the Airline table.
  17. Drag the Airline table from the Connection pane to the Master pane.
  18. On the File menu, choose Save.
  19. In the Local Projects pane, right-click MongoDB, choose New and then choose New Business Layer.

    The New Business Layer dialog box is displayed.

  20. Select Relational Data Foundation, and then choose Next.
  21. Enter MongoDB in the Resource Name box, and then choose Next.
  22. Select MongoDB.dfx in the Select data foundation list, and then choose Finish.
  23. In the Business Layer pane, expose the columns in the Airline table.
  24. Select the Id column. In the Dimension pane, change dbo.airline._id to 'dbo.airline._id'. On the File menu, choose Save.
  25. In the Local Projects pane, right-click MongoDB.blx, click Publish, and then click To A Repository.

    The Publish Universe wizard starts.

  26. Choose Next, and then choose Finish.

    Your Universe is now available to the various BusinessObjects reporting tools. The remaining steps in this section will use Web Intelligence Rich Client to illustrate this.

  27. On the BusinessObjects Client tools machine, start the Web Intelligence Rich Client.
  28. In the New Document pane, in the Choose a data source to create a document section choose More.
  29. Log in to your BusinessObjects Central Management Server when prompted.

    The Universe dialog box is displayed.

  30. Select MongoDB.unx and then choose Select.

    Query Panel starts.

  31. Drag the Airline table from the Universe outline pane to the Result objects pane.
  32. Choose the Run Query button.

    The MongoDB data is displayed in the Web Intelligence document.

Connecting SAP Crystal Reports to MongoDB

These steps show you how to analyse and interpret your MongoDB data in Crystal Reports:

  1. In Crystal Reports, create a new report.
  2. In the Standard Report Creation Wizard, in the Available Data Sources pane, expand the Create New Connection list.
  3. Expand the ODBC (RDO) list.
  4. In the ODBC (RDO) dialog box, in the Data Source Name list, choose your MongoDB ODBC data source. Choose Finish.
  5. Select the tables that you want include in your report, and then choose Next.
  6. Progress the Wizard to select the fields and fields that you want to include in your report.
  7. Click Finish to generate the report based on the MongoDB data.

Connecting SQL Server (linked server or SSIS) to MongoDB

Linked server

These steps show you how to use a linked server to work with MongoDB data, just as if you were working with data stored in a SQL Server table:

  1. In Microsoft SQL Server Management Studio, connect to the SQL Server instance you want to create the linked server against.

    You need to log on with an account that is a member of the SQL Server sysadmin fixed server role to create a linked server.

  2. Right-click Server Objects. From the pop-up menu choose New > Linked Server.
  3. In the Linked server box, enter MongoDB.
  4. From the Provider list, choose Microsoft OLE DB Provider for ODBC Drivers.
  5. In the Data source box, enter the name of your MongoDB ODBC data source, and then choose OK.

    SQL Server verifies the linked server by testing the connection.

    • If you get the error "Specified driver could not be loaded due to system error 126: The specified module could not be found," choose Yes when prompted whether to keep the linked server. You need to restart your SQL Server instance before you can use the linked server. If SQL Server was already running when you installed the MongoDB ODBC driver, it will not have the latest version of the system PATH environment variable. The MongoDB ODBC driver Setup program adds entries for the driver to the system PATH. Restarting the instance makes these changes available to SQL Server, allowing it to load the MongoDB ODBC driver.
    • If you made a mistake when specifying the MongoDB ODBC data source, you get the error "Data source name not found and no default driver specified." If you get this error, choose No when prompted whether to keep the linked server and edit the value in the Data source box.
  6. You can query your MongoDB data either by using a:
    • Four part table name in a distributed query.

      A four part table name has the format:

      server_name.[database_name].[schema_name].table_name.

      The schema that the driver returns is dbo. Include these identifiers in your SQL statements. For example:

      SELECT * FROM MONGODB.faa.dbo.airline

      The capitalisation of the table name must be the same as it is in MongoDB. For example, the following query is invalid:

      SELECT * FROM MONGODB.faa.dbo.AIRLINE

      To check the capitalisation of the MongoDB tables, run:

      EXEC sp_tables_ex @table_server = 'MONGODB'
    • Pass-through query in an OPENQUERY function. For example:
      SELECT * FROM OPENQUERY(MONGODB, 'SELECT * FROM airline')

      SQL Server sends pass-through queries as uninterpreted query strings to the MongoDB ODBC driver. This means that SQL Server does not apply any kind of logic to the query or try to estimate what that query will do.

Schema Editor Note

If you apply a schema to your MongoDB data, you may need to do the following before SQL Server uses the schema:

You apply a schema by creating one in the Schema Editor and then configuring your data source to tell the MongoDB ODBC driver where the schema is stored.

An example usage case for using the Schema Editor with SQL Server is:

  1. You get the error "Requested conversion not supported" when attempting to retrieve some MongoDB data.
  2. The underlying reason for the error is that the MongoDB ODBC driver is correctly describing some MongoDB data to SQL Server as an NVARCHAR(n), but n is greater than the maximum length that SQL Server supports for this data type.
  3. You use the Schema Editor to change the length for this column to 4000. You save the schema.
  4. You apply the schema by specifying the location of the schema in your MongoDB ODBC data source (you specify machine and the MongoDB database where the schema is stored.)

SQL Server Integration Services (SSIS)

These instructions show you how to use a linked server to work with MongoDB data, just as if you were working with data stored in a SQL Server table. The instructions assume that you have Microsoft Visual Studio and SQL Server Data Tools for Visual Studio installed.

You will be importing data from a MongoDB table into a SQL Server table, which you first need to create:

  1. In Microsoft SQL Server Management Studio, connect to the SQL Server instance that serves the database where you want to insert the MongoDB data.
  2. Choose New Query, and then run the following SQL statement:
    create table airline (_id varchar(255) NOT NULL, UNIQUE_CARRIER varchar(255),
                           AIRLINE_ID int, CARRIER varchar(255), TAIL_NUM varchar(255),
                           FL_NUM int)

Now create an SSIS job to populate the data:

  1. In Visual Studio, create a new Integration Services Project.
  2. Drag a Data Flow Task from the Toolbox to the Control Flow tab.
  3. Choose the Data Flow tab.
  4. Drag an ODBC Source from the Toolbox to the Data Flow tab, and then press Return.

    ODBC Source is under the Other Sources list.

  5. In the ODBC Source Editor, choose New.
  6. In the Configure ODBC Connection Manager dialog box, choose New.
  7. In the Connection Manager dialog box, choose your MongoDB ODBC data source from the Use user or system data source name list. Use the OK button to return to the ODBC Source dialog box.
  8. In the Data access mode list, choose Table Name.
  9. In the Name of the table or view list, choose dbo.airline.
  10. Choose Preview, and then choose OK to exit the dialog boxes.
  11. Name your ODBC Source MongoDB Airline.
  12. Drag a SQL Server Destination from the Toolbox to the Data Flow tab, below MongoDB Airline, and then press Return.

    SQL Server Destination is under the Other Destinations list.

  13. Select MongoDB Airline and then drag the blue arrow over to the SQL Server Destination.
  14. Select the SQL Server Destination and press Return.
  15. In the SQL Server Destination Editor dialog box, choose the SQL Server instance that serves the database where you created the Airline table.
  16. In the Use a table or view list, choose the Airline table.
  17. Click Mappings, and then choose OK.
  18. Name the SQL Server Destination SQL Server Airline.
  19. Name the Execute SQL Task Update Last Load Date.
  20. Choose the Start button to retrieve and insert the MongoDB data into SQL Server.

Connecting Tableau to MongoDB

These instructions show you how to to connect Tableau Desktop to MongoDB and provide real time access to MongoDB, enabling you to analyse MongoDB data from your Tableau dashboard.

  1. In Tableau Desktop, on the Data menu, choose Connect To Data.
  2. In the Connect To Data page's On a server section, choose Other Databases (ODBC).
  3. In the Generic ODBC Connection dialog box, choose the MongoDB ODBC driver data source from the DSN list, and then click Connect.
  4. Use the Table section of the dialog box to retrieve the MongoDB data that you want to work with.

    For example, to work with a single object, choose Single Table and then select the magnifying glass beneath. In the Select Table dialog box, choose Load. Choose the object that you want to work with, and then choose Select.

  5. Enter a name for the ODBC connection in the space provided (or accept the default value), and then click OK.
  6. Note the capabilities reported by Tableau for the data source, and then choose OK.
  7. The MongoDB ODBC driver provides real time access to your MongoDB data and so you can choose Connect Live.

    Your MongoDB data is now ready for use in Tableau.

Connecting TIBCO Spotfire to MongoDB

The following instructions show you how to analyse MongoDB data from your Spotfire dashboard.

  1. In Spotfire Desktop, choose Other, in the Add Data Connection section.

    The Add Data Tables dialog box is displayed.

  2. Choose the Add > Other > Database button.

    The Open Database dialog box is displayed.

  3. In the Data source type list, choose Odbc Data Provider, and then choose Configure.

    The Configure Data Source Connection dialog box is displayed.

  4. In the System or user data source list, choose your MongoDB ODBC data source, and then choose OK to dismiss the dialog boxes.

    The Specify Tables and Columns dialog box is displayed.

  5. Expand the Tables, views and columns tree, and then select airline.
  6. In the Data source Name box, enter Easysoft MongoDB, and then choose OK twice.

    Spotfire retrieves the MongoDB airline data and displays it using the default visualisation.