Connecting to MongoDB

Concept Information

ACCESSDATA command

MongoDB is a cloud data service. You can use the MongoDB data connector to import your organization's MongoDB data.

Note

Analytics provides MongoDB as an optional connector and if it is not available in your Data Access window, it is likely that the connector was not selected during installation. For more information, see Install optional Analytics data connectors and Python engine.

Before you start

To connect to MongoDB, you must gather the following:

  • server name or IP address of the server hosting the MongoDB database

  • correct connection port
  • name of MongoDB database

For help gathering the connection prerequisites, contact the MongoDB administrator in your organization. If your administrator cannot help you, you or your administrator should contact MongoDB Support.

Create a MongoDB connection

  1. From the Analytics main menu, select Import > Database and application.
  2. From the New Connections tab, in the ACL Connectors section, select MongoDB.

    Tip

    You can filter the list of available connectors by entering a search string in the Filter connections box. Connectors are listed alphabetically.

  3. In the Data Connection Settings panel, enter the connection settings and at the bottom of the panel, click Save and Connect.

    You can accept the default Connection Name, or enter a new one.

The connection for MongoDB is saved to the Existing Connections tab. In the future, you can reconnect to MongoDB from the saved connection.

Once the connection is established, the Data Access window opens to the Staging Area and you can begin importing data. For help importing data from MongoDB, see Working with the Data Access window.

Connection settings

Basic settings

Setting Description Example
Server The host name or IP address of the server hosting the MongoDB database.  
Port

The number of the TCP port that the MongoDB server uses to listen for client connections.

The default value is 27017.

27017
Database The name of the MongoDB database.  
Connect to Replica Set

Specifies whether the driver can access replica sets in your MongoDB implementation:

  • Disabled - The driver cannot access replica sets.

  • Enabled - The driver can access replica sets in your MongoDB implementation.
Disabled
Replica Set Name The name of the replica set for the driver to access.  
Secondary Servers

A comma-separated list of the servers to use when connecting to a replica set.

To indicate the TCP port that the server is using to listen for client connections, append a colon (:) and the port number to the server name or IP address.

 
Authentication Mechanism

The authentication mechanism that MongoDB will use to authenticate the connection:

  • No Authentication - The driver does not authenticate the connection.

  • MongoDB User Name and Password - The driver authenticates using the SCRAM-SHA-1 protocol, which is the default authentication protocol used by MongoDB.

  • Kerberos - The driver authenticates using the Kerberos protocol.

  • LDAP - The driver authenticates using the LDAP protocol.
No Authentication
Service name The Kerberos service principal name of the MongoDB server. mongodb
Authentication Source

The name of the MongoDB database for authentication.

This value is needed only if the authentication database is different from the database to retrieve data.

admin
Username The username used to authenticate with MongoDB.  
Password The password used to authenticate with MongoDB.  

Advanced settings

Setting Description Example
Enable SSL Specifies whether the driver uses SSL to connect to the server. Disabled
Allow Self-signed Certificate Specifies whether the driver allows self-signed SSL certificates from the server. Disabled
PEM Key File The full path of the .pem file containing the certificate for verifying the client.  
PEM Key Password The password of the client certificate file that is specified in the PEM Key File field.  
Certificate Authority File The full path of the .pem file that you use to verify the server.  
Certificate Authority Directory The full path of the directory containing the .pem files to verify the server. This setting enables the driver to access multiple .pem files for SSL verification.  
Certificate Revocation List File The full path of the .pem file containing the list of revoked certificates.  
Enable Double-Buffering

Specifies whether the driver retrieves the data using double-buffering.

MongoDB driver is capable of using double-buffering to improve driver performance during SELECT operations.

Enabled
Expose strings as SQL_WVARCHAR

Specifies whether the string data type is mapped to SQL_WVARCHAR or SQL_VARCHAR.

Enabled
Expose binary as SQL_LONGVARBINARY Specifies whether the driver returns binary columns as data of type SQL_LONGVARBINARY or SQL_VARBINARY. Enabled
Enable Passdown Specifies whether the driver optimizes joins between virtual tables, and passes filtering and aggregation optimizations to the MongoDB database for handling. Enabled
Documents to fetch per block

The maximum number of documents that a query returns at a time. This setting also determines the buffer size used when double-buffering is enabled.

The default value is 4096.

4096
String Column Size

The maximum number of characters that can be contained in STRING columns.

The default value is 255.

255
Binary Column Size

The maximum data length for binary columns.

The default value is 32767.

32767
Metadata Mechanism

Specifies where the driver looks for the schema definition:

  • Database - The driver loads the schema definition from the MongoDB database.
  • Local File - The driver loads the schema definition from the JSON file specified in the Local File field.
Database
Local file The full path of a local JSON file containing the schema definition that you want the driver to use when connecting to MongoDB.  
Sampling Method

Specifies how the driver samples data when generating a temporary schema definition:

  • Forward - The driver samples data sequentially, starting from the first record in the database.
  • Backwards: The driver samples data backwards starting from the last record in the database.

Forward
Documents to sample (0 for all documents)

Maximum number of records that the driver can sample to generate a temporary schema definition.

When this option is set to 0, the driver samples every document in the database.

The default value is 100.

100
Sampling Step Size

The interval at which the driver samples records when scanning through the database to generate a temporary schema definition. For example, if you set this option to 2, then the driver samples every second record in the database.

The default value is 1.

1
Writeback Batch Size (1-1000)

The maximum number of documents that the driver can handle at one time during a write operation.

The default value is 500.

500
Write Concern

Total number of primary and secondary servers that must acknowledge a write operation for the driver to report a successful write operation.

When this option is set to 0, the driver does not require write operations to be acknowledged.

The default value is 1.

1
Write Concern Timeout

Maximum number of seconds that the driver waits for a secondary server to acknowledge a write operation before reporting that the operation has failed.

When this option is set to 0, the driver does not time out. Instead, the driver waits until all secondary servers acknowledge the write operation, and then reports that the operation has succeeded.

The default value is 0.

0
Write Concern Journaled Writes Specifies whether the driver requires the data from a write operation to be committed to the journal before the write operation can be acknowledged. Disabled

Data connector updates

When you upgrade Analytics, the Robots Agent, or AX Server, you should test any of your scripts that import data using one of the Analytics data connectors (ACCESSDATA command).

The possibility exists that changes made by third-party data sources or ODBC driver vendors required updates to one or more of the data connectors. Scripted data connections may need to be updated in order to continue working correctly.

  • Re-run the import The easiest way to update a connection is to manually perform an import using the Data Access window in the upgraded version of Analytics. Copy the ACCESSDATA command from the log and use it to update your script.

    Note

    Before connecting to a data source and re-running the import, clear the connector cache to flush the existing set of table names.

    In the Existing Connections tab in the Data Access window, beside the connector name, select > Clear cache.

  • Update field specifications You may also need to update field specifications in the script body to align with table schema changes in the data source or ODBC driver. Possible changes include field names, field data types, and field and record lengths.
  • Check the results of any filtering You should also check the results of any filtering that you apply as part of the data import. Confirm that the import filtering is including and excluding records correctly.

MongoDB data connector changes

Specific changes made to the MongoDB data connector are listed below.

Analytics version Change

14.2

The connector no longer supports connecting to MongoDB 3.0 and 3.2.

Connections can be made to MongoDB 3.4, 3.6, and 4.0.