Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To...

26
Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide February 3, 2014 Simba Technologies Inc.

Transcript of Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To...

Page 1: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector

for MongoDB

Installation and Configuration Guide

February 3, 2014

Simba Technologies Inc.

Page 2: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www.s imba.com i

Copyright ©2012-2013 Simba Technologies Inc. All Rights Reserved.

Information in this document is subject to change without notice. Companies, names and data used in examples herein are fictitious unless otherwise noted. No part of this publication, or the software it describes, may be reproduced, transmitted, transcribed, stored in a retrieval system, decompiled, disassembled, reverse-engineered, or translated into any language in any form by any means for any purpose without the express written permission of Simba Technologies Inc.

Trademarks

Simba, the Simba logo, SimbaEngine, SimbaEngine C/S, SimbaExpress and SimbaLib are registered trademarks of Simba Technologies Inc. All other trademarks and/or servicemarks are the property of their respective owners.

ICU License - ICU 1.8.1 and later

COPYRIGHT AND PERMISSION NOTICE

Copyright (c) 1995-2010 International Business Machines Corporation and others

All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.

All trademarks and registered trademarks mentioned herein are the property of their respective owners.

OpenSSL

Copyright (c) 1998-2008 The OpenSSL Project. All rights reserved.

Page 3: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www.s imba.com ii

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. All advertising materials mentioning features or use of this software must display the following acknowledgment:

"This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)"

4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [email protected].

5. Products derived from this software may not be called "OpenSSL" nor may "OpenSSL" appear in their names without prior written permission of the OpenSSL Project.

6. Redistributions of any form whatsoever must retain the following acknowledgment:

"This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/)"

THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Expat

Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NOINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR

Page 4: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www.s imba.com iii

COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contact Us

Simba Technologies Inc. 938 West 8th Avenue Vancouver, BC Canada V5Z 1E5

www.simba.com

Telephone: +1 (604) 633-0008 Information and Product Sales: Extension 2 Technical Support: Extension 3

Fax: +1 (604) 633-0004

Information and Product Sales: [email protected] Technical Support: [email protected] Follow us on Twitter: @SimbaTech

Printed in Canada

Page 5: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www.s imba.com iv

Table of Contents Introduction ................................................................................................................................................ 1

Windows Driver .......................................................................................................................................... 1 System Requirements ......................................................................................................................... 1 Installing the Driver ............................................................................................................................ 1 Creating a Data Source Name .......................................................................................................... 2 Configuring Advanced Options ........................................................................................................ 3 Defining the Schema .......................................................................................................................... 5

Linux Driver ................................................................................................................................................. 6 System Requirements ......................................................................................................................... 6 Installation Using the RPM ............................................................................................................... 7 Installation Using the Tarball Package ........................................................................................... 8 Setting the LD_LIBRARY_PATH Environment Variable .............................................................. 8

Mac OS X Driver ......................................................................................................................................... 9 System Requirements ......................................................................................................................... 9 Installation ............................................................................................................................................. 9

Configuring ODBC Connections for Linux and Mac OS X............................................................. 10 Files ........................................................................................................................................................ 10 Sample Files ......................................................................................................................................... 10 Configuring the Environment ........................................................................................................ 11 Configuring the odbc.ini File .......................................................................................................... 11 Configuring the odbcinst.ini File ................................................................................................... 12 Configuring the simba.mongodbodbc.ini File ............................................................................ 13

Features ...................................................................................................................................................... 14 SQL Connector .................................................................................................................................... 14 Data Types ............................................................................................................................................ 14 Authentication.................................................................................................................................... 16 Catalog Support ................................................................................................................................. 16 Write-back ........................................................................................................................................... 16

Contact Us ................................................................................................................................................. 18

Appendix: Driver Configuration Options ........................................................................................... 19

Page 6: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 1

Introduction The Simba ODBC Driver with SQL Connector for MongoDB enables Business Intelligence (BI), analytics and reporting on data that is stored in MongoDB databases. The driver complies with the ODBC 3.52 data standard and adds important functionality such as Unicode, as well as 32- and 64-bit support for high-performance computing environments on all platforms.

ODBC is one of the most established and widely supported APIs for connecting to and working with databases. At the heart of the technology is the ODBC driver, which connects an application to the database. For more information about ODBC, see http://www.simba.com/odbc.htm. For complete information on the ODBC specification, see the ODBC API Reference at http://msdn.microsoft.com/en-us/library/windows/desktop/ms714562(v=vs.85).aspx

Simba ODBC Driver with SQL Connector for MongoDB is available for the Microsoft® Windows® and Linux operating systems.

Windows Driver

System Requirements You can install Simba ODBC Driver with SQL Connector for MongoDB on client computers accessing MongoDB databases. Each computer where you install the driver must meet the following minimum system requirements:

• One of the following operating systems (32- and 64-bit editions are supported):

o Windows® XP with SP3

o Windows® Vista

o Windows® 7 Professional

o Windows® Server 2008 R2

• 25 MB of available disk space

Important: To install the driver, you need Administrator privileges on the computer.

Installing the Driver On 64-bit Windows operating systems, you can execute 32- and 64-bit applications transparently. You must use the version of the driver matching the bitness of the client application accessing MongoDB databases:

• SimbaMongoDBODBC32.msi for 32-bit applications

• SimbaMongoDBODBC64.msi for 64-bit applications

You can install both versions of the driver on the same computer.

Page 7: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 2

Note: For an explanation of how to use ODBC on 64-bit editions of Windows, see http://www.simba.com/docs/HOW-TO-32-bit-vs-64-bit-ODBC-Data-Source-Administrator.pdf

To install Simba ODBC Driver with SQL Connector for MongoDB:

1. Depending on the bitness of your client application, double-click to run SimbaMongoDBODBC32.msi or SimbaMongoDBODBC64.msi

2. Click Next

3. Select the check box to accept the terms of the License Agreement if you agree, and then click Next

4. To change the installation location, click the Change button, then browse to the desired folder, and then click OK. To accept the installation location, click Next

5. Click Install

6. When the installation completes, click Finish

7. If you are installing a driver with an evaluation license and you have purchased a perpetual license, then copy the License.lic file you received via e-mail into the \lib subfolder in the installation folder you selected in step 4.

Creating a Data Source Name After installing Simba ODBC Driver with SQL Connector for MongoDB, you need to create a Data Source Name (DSN).

To create a Data Source Name:

1. On the Windows Start menu, click All Programs, then click the Simba MongoDB ODBC Driver 0.4 program group corresponding to the bitness of the client application accessing MongoDB databases, and then click ODBC Administrator

2. In the ODBC Administrator, click the Drivers tab, and then scroll down as needed to confirm that Simba MongoDB ODBC Driver appears in the alphabetical list of driver names.

3. To create a DSN on the computer that only the user currently logged into Windows can use, click the User DSN tab.

OR

To create a DSN on the computer that all users who log into Windows can use, click the System DSN tab.

4. Click the Add button.

5. In the Create New Data Source dialog, select Simba MongoDB ODBC Driver, and then click Finish

6. In the Simba MongoDB ODBC Driver Setup dialog, type a name for the data source in the Data Source Name field.

7. In the Description field, type relevant details about the DSN.

Page 8: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 3

8. In the Host field, type the name or IP address of the host where the MongoDB instance runs.

9. In the Port field, type the number of the port that the MongoDB instance uses.

10. In the Database field, type the name of the MongoDB database to which the client application needs to connect.

11. In the Username field, type the appropriate login credential for the DSN to provide when accessing the MongoDB database.

12. To configure advanced driver options, click the Advanced Options button. For details, see the section Configuring Advanced Options on page 3.

13. If you need to customize the schema that Simba ODBC Driver with SQL Connector for MongoDB detects for a MongoDB database, then click the Schema Definition button. For details, see the section Defining the Schema on page 5.

14. Click OK to close the Simba MongoDB ODBC Driver Setup dialog.

Note: Currently, the Test button is not implemented.

15. Click OK to close the ODBC Data Source Administrator dialog.

Configuring Advanced Options For a list and description of advanced configuration settings available in Simba ODBC Driver with SQL Connector for MongoDB, see the Appendix: Driver Configuration Options on page 19.

You can configure advanced options using the following:

• Data Source Name

• Database connection string

Using the Data Source Name

To set advanced options using the Simba MongoDB Driver Setup dialog:

1. In the ODBC Data Source Administrator where you created the DSN, select the DSN tab where the Data Source Name appears, and then select the Data Source Name.

2. Click the Configure button, and then click the Advanced Options button.

3. Type an appropriate value in the Rows Fetched Per Block field, as needed.

4. Type an appropriate value in the Nested Column Separator column, as needed.

5. Type an appropriate value in the Rows To Scan field, as needed.

6. Click the drop-down arrow next to the Read Preference field, and then select the appropriate option as needed.

7. Select or clear the available check boxes, as needed:

• Use SQL_WVARCHAR for String data type

Page 9: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 4

• Enable authentication

• Enable Metadata caching

• Omit default NULL columns on insert

• Truncate documents larger than 16MB

• Enable reading/writing as JSON document

8. In the String Column Lengths area, click the drop-down arrows next to the Standard, Container and DocumentAsJSON fields as needed, and then select appropriate values. You can also type values in the fields.

9. In the Update Configuration area, select or deselect the available check boxes, as needed:

• Enable updating multiple rows

• Upsert on update

10. In the Get Metadata From area, select Database or Local File. If you select Local File, then click the Browse button, then select the file from which to load metadata, and then click Open

11. In the Advanced Options dialog, click OK

12. In the Simba MongoDB ODBC Driver Setup dialog, click OK

Using a DSN-less Connection

Some applications provide support for connecting to a data source using a driver without a DSN.

Here is an example of the minimum required attributes for a connection string without authentication:

Driver=Simba MongoDB ODBC Driver; Host=192.168.100.100; Port=27017; Database=MyDatabase;

Here is an example of the minimum required attributes for a connection string with authentication:

Driver=Simba MongoDB ODBC Driver; Host=192.168.101.101; Port=27018; Database=MyDatabase; EnableAuthentication=1; UID=MyUsername; PWD=MyPassword;

Here is an example connection string that sets some advanced options:

Driver=Simba MongoDB ODBC Driver; Host=192.168.100.100; Port=27017;

Page 10: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 5

Database=MyDatabase; UID=MyUsername; PWD=MyPassword; RowsFetchedPerBlock=4096; DefaultStringColumnLength=255; DefaultContainerColumnLength=511; DefaultJSONColumnLength=1023; UseSqlWVarchar=0; CacheMetadata=0

Defining the Schema Simba ODBC Driver with SQL Connector for MongoDB dynamically detects the database schema as needed in the process of connecting to a MongoDB database. You can also edit the schema that the driver uses to connect to the database manually.

To define manually the schema to use when Simba ODBC Driver with SQL Connector for MongoDB connects to the database:

1. In the ODBC Data Source Administrator where you created the DSN, select the DSN tab where the Data Source Name appears, and then select the Data Source Name.

2. Click the Configure button, and then click the Schema Definition button.

3. If authentication is enabled, then you are prompted to provide your login credentials. Type the database to which you want to connect, your user name and password, and then click OK

4. In the Schema Definition dialog, click the drop-down arrow next to the Table Name field, and then select the table for which you want to edit the schema.

5. To filter sample data, type an appropriate JSON filter in the JSON Filter field, and then click the Resample button. In the confirmation dialog, click Yes

Note: The value in the Rows to Scan field in the Advanced Options dialog determines the maximum number of rows in the table that the driver samples to detect columns and corresponding data types. Rows are sampled after any JSON filter is applied.

6. To edit columns defined in the schema:

a) To rename a column, select the column name, then click the column name, then type a new name for the column, and then press ENTER

b) To change the data type for a column, click the Type field for the column, and then click the appropriate data type.

c) To change the MongoDB data type for a column, click the Source Type field for the column, and then click the appropriate data type.

d) To show or hide an auto-detected column, click the Hide Column field for the column, and then click Show or Hide as needed.

e) Repeat steps a) to d) to edit more columns, as needed.

Page 11: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 6

7. To add columns to the schema for the table:

a) Click the Add button. In the Columns area, a new entry named New column is created and selected.

b) Type a name for the column to add, and then press ENTER

c) In the Columns area, scroll as needed to view the column you created in step b), then click the Type field for the new column, and then click the appropriate data type.

d) Repeat steps a) to c) to add more columns, as needed.

8. To delete columns from the schema:

a) In the Columns area, select the name(s) of the column(s) to delete.

b) Click the Remove button.

9. Repeat steps 4 to 8 as needed to edit the schemas of other tables in the database.

Note: The Data Preview pane displays sample data from the table based on the currently defined schema.

10. In the Options area, select whether to store the schema you defined manually in the database or in the file you specified in the Advanced Options dialog.

11. When you are finished defining the schema, click OK, and then click Yes when prompted to write metadata to the database.

OR

To discard changes, click the Cancel button, and then click Yes when prompted to discard changes.

If you store schema data—metadata—in the database, then the metadata is stored in a collection called Mersenne_Collection_Metadata. As needed, you can copy the collection to other MongoDB instances to duplicate the schema definition.

Note: Deleting Mersenne_Collection_Metadata deletes the schema definition you defined.

Linux Driver

System Requirements Each computer where you install the driver must meet the following minimum system requirements:

• Red Hat® Enterprise Linux® (RHEL) 5.0, CentOS 5.0 or SUSE Linux Enterprise Server (SLES) 11 (32 and 64-bit editions are supported)

• 45 MB of available disk space

Page 12: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 7

• An installed ODBC driver manager:

o iODBC 3.52.7 or above

OR

o unixODBC 2.2.12 or above

Installation Using the RPM

You can install the driver using RPMs. There are two versions of the driver for Linux:

• SimbaMongoDBODBC-32bit-Version-Release.rpm—32-bit driver • SimbaMongoDBODBC-Version-Release.rpm—64-bit driver

The version of the driver that you select should match the bitness of the client application accessing your MongoDB-based data. For example, if the client application is 64-bit, then you should install the 64-bit driver. Note that 64-bit editions of Linux support both 32- and 64-bit applications. Verify the bitness of your intended application and install the appropriate version of the driver.

Important: Ensure that you install the driver using the RPM corresponding to your Linux distribution.

Simba ODBC Driver with SQL Connector for MongoDB driver files are installed in the following directories:

• /opt/simba/mongodbodbc/ErrorMessages—Error messages files directory

• /opt/simba/mongodbodbc /Setup—Sample configuration files directory

• /opt/simba/mongodbodbc /lib/32—32-bit shared libraries directory

• /opt/simba/mongodbodbc /lib/64—64-bit shared libraries directory

To install Simba ODBC Driver with SQL Connector for MongoDB:

1. In Red Hat Enterprise Linux 5.0 or CentOS 5.0, log in as the root user, then navigate to the folder containing the driver RPM packages to install, and then type the following at the command line, where RPMFileName is the file name of the RPM package containing the version of the driver that you want to install:

yum --nogpgcheck localinstall RPMFileName

OR

In SUSE Linux Enterprise Server 11, log in as the root user, then navigate to the folder containing the driver RPM packages to install, and then type the following at the command line, where RPMFileName is the file name of the RPM package containing the version of the driver that you want to install:

zypper install RPMFileName

Page 13: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 8

2. If you are installing a driver with an evaluation license and you have purchased a perpetual license, then copy the License.lic file you received via e-mail into the /opt/simba/ mongodbodbc /lib/32 or /opt/simba/ mongodbodbc /lib/64 folder, depending on the version of the driver you installed.

Installation Using the Tarball Package

Alternately, the Simba ODBC Driver with SQL Connector for MongoDB is available for installation using a TAR.GZ tarball package. The tarball package includes:

• [INSTALL_DIR]/simba/mongodbodbc/ contains release notes, the Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide in PDF format and a Readme.txt file that provides plain text installation and configuration instructions.

• [INSTALL_DIR]/simba/mongodbodbc/lib/32 contains the 32-bit Simba MongoDB ODBC Driver for Linux.

• [INSTALL_DIR]/simba/mongodbodbc/lib/64 contains the 64-bit Simba MongoDB ODBC Driver for Linux.

• [INSTALL_DIR]/simba/mongodbodbc/ErrorMessages contains error message files required by the Simba MongoDB ODBC Driver.

• [INSTALL_DIR]/simba/mongodbodbc/Setup contains configuration files named odbc.ini, odbcinst.ini, and simba.mongodbodbc.ini

Setting the LD_LIBRARY_PATH Environment Variable

The LD_LIBRARY_PATH environment variable must include the paths to:

• Installed ODBC driver manager libraries

• Installed Simba ODBC Driver with SQL Connector for MongoDB shared libraries

Important: While you can have both 32- and 64-bit versions of the driver installed at the same time on the same computer, do not include the paths to both 32- and 64-bit shared libraries in LD_LIBRARY PATH at the same time. Only include the path to the shared libraries corresponding to the driver matching the bitness of the client application used.

For example, if you are using a 64-bit client application and ODBC driver manager libraries are installed in /usr/local/lib, then set LD_LIBRARY_PATH as follows, where InstallDir is /opt if you installed the driver using the RPM or your installation directory if you installed the driver using the tarball:

export LD_LIBRARY_PATH=/usr/local/lib:InstallDir/simba/mongodbodbc/ lib/64

Refer to your Linux shell documentation for details on how to set environment variables permanently.

Page 14: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 9

For details on creating ODBC connections using Simba ODBC Driver with SQL Connector for MongoDB, see Configuring ODBC Connections for Linux and Mac OS X on page 10.

Mac OS X Driver

System Requirements Each computer where you install the driver must meet the following minimum system requirements:

• Mac OS X version 10.6.8 or later

• 100 MB of available disk space

• iODBC 3.52.7 or above

Installation

Simba ODBC Driver with SQL Connector for MongoDB driver files are installed in the following directories:

• /opt/simba/mongodbodbc/ErrorMessages—Error messages files directory

• /opt/simba/mongodbodbc/Setup—Sample configuration files directory

• /opt/simba/mongodbodbc/lib/universal—Binaries directory

To install Simba ODBC Driver with SQL Connector for MongoDB:

1. Double-click to mount the SimbaMongoDBODBC.dmg disk image.

2. Double-click SimbaMongoDBODBC.pkg to run the Installer.

3. Follow the instructions in the Installer to complete the installation process.

4. When the installation completes, click Close

5. If you are installing a driver with an evaluation license and you have purchased a perpetual license, then copy the License.lic file you received via e-mail into the /opt/simba/mongodbodbc/lib/universal folder.

Setting the DYLD_LIBRARY_PATH Environment Variable

The DYLD_LIBRARY_PATH environment variable must include the paths to:

• Installed ODBC driver manager libraries

• Installed Simba ODBC Driver with SQL Connector for MongoDB shared libraries

For example, if ODBC driver manager libraries are installed in /usr/local/lib, then set DYLD_LIBRARY_PATH as follows:

Page 15: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 10

export DYLD_LIBRARY_PATH=/usr/local/lib:/opt/simba/mongodbodbc/lib/ universal

Refer to your Mac OS X shell documentation for details on how to set environment variables permanently.

For details on creating ODBC connections using Simba ODBC Driver with SQL Connector for MongoDB, see Configuring ODBC Connections for Linux and Mac OS X on page 10.

Configuring ODBC Connections for Linux and Mac OS X

Files

ODBC driver managers use configuration files to define and configure ODBC data sources and drivers. By default, the following configuration files residing in the user’s home directory are used:

• .odbc.ini – The file used to define ODBC data sources (required)

• .odbcinst.ini – The file used to define ODBC drivers (optional)

• .simba.mongodbodbc.ini – The file used to configure Simba ODBC Driver with SQL Connector for MongoDB (required)

Sample Files

The driver installation contains the following sample configuration files in the Setup directory:

• odbc.ini

• odbcinst.ini

• simba.mongodbodbc.ini

The names of the sample configuration files do not begin with a period (.) so that they will appear in directory listings by default. A filename beginning with a period (.) is hidden. For odbc.ini and odbcinst.ini, if the default location is used, then the filenames must begin with a period (.). For simba.mongodbodbc.ini, the filename must begin with a period (.) and must reside in the user’s home directory.

If the configuration files do not already exist in the user’s home directory, then the sample configuration files can be copied to that directory and renamed. If the configuration files already exist in the user’s home directory, then the sample configuration files should be used as a guide for modifying the existing configuration files.

Page 16: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 11

Configuring the Environment

While the odbc.ini, odbcinst.ini and simba.mongodbodbc.ini configuration files reside in the user’s home directory by default, you can use three environment variables—ODBCINI, ODBCSYSINI, and SIMBAINI—to specify different locations for the files. Set ODBCINI to point to your odbc.ini file. Set ODBCSYSINI to point to the directory containing the odbcinst.ini file. Set SIMBAINI to point to your simba.mongodbodbc.ini file. For example, if your odbc.ini and simba.mongodbodbc.ini files are located in the folder /etc and your odbcinst.ini file is located in the folder /usr/local/odbc, then set the environment variables as follows:

export ODBCINI=/etc/odbc.ini

export ODBCSYSINI=/usr/local/odbc

export SIMBAINI=/etc/simba.mongodbodbc.ini

The following search order is used to locate the simba.mongodbodbc.ini file:

1. If the SIMBAINI environment variable is defined, then the driver searches for the file specified by the environment variable.

Important: SIMBAINI must contain the full path, including the filename.

2. The current working directory of the application is searched for a file named simba.mongodbodbc.ini not beginning with a period.

3. The directory ~/ (that is, $HOME) is searched for a hidden file named .simba.mongodbodbc.ini

4. The directory /etc is searched for a file named simba.mongodbodbc.ini not beginning with a period.

Configuring the odbc.ini File

ODBC Data Sources are defined in the odbc.ini configuration file. The file is divided into several sections:

• [ODBC] is optional and used to control global ODBC configuration, such as ODBC tracing.

• [ODBC Data Sources] is required, listing DSNs and associating DSNs with a driver.

• A section having the same name as the data source specified in the [ODBC Data Sources] section is required to configure the data source.

Here is an example odbc.ini configuration file for Linux:

[ODBC Data Sources]

Sample Simba MongoDB DSN 32=Simba MongoDB ODBC Driver 32-bit

[Sample Simba MongoDB DSN 32]

Driver=/opt/simba/mongodbodbc/lib/32/libsimbamongodbodbc32.so

HOST=MyMongoDBServer

PORT=10000

Page 17: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 12

Here is an example odbc.ini configuration file for Mac OS X:

[ODBC Data Sources]

Sample Simba MongoDB DSN=Simba MongoDB ODBC Driver

[Sample Simba MongoDB DSN]

Driver=/opt/simba/mongodbodbc/lib/universal/libsimbamongodbodbc.dylib

HOST= MyMongoDBServer

PORT=10000

To create a data source:

1. Open the .odbc.ini configuration file in a text editor.

2. Add a new entry to the [ODBC Data Sources] section. Type the data source name (DSN) and the driver name.

3. To set configuration options, add a new section having a name matching the data source name (DSN) you specified in step 2. Specify configuration options as key-value pairs.

4. Save the .odbc.ini configuration file.

For details on configuration options available to control the behavior of DSNs using Simba ODBC Driver with SQL Connector for MongoDB, see Appendix: Driver Configuration Options on page 19.

Configuring the odbcinst.ini File

ODBC Drivers are defined in the odbcinst.ini configuration file. The configuration file is optional because drivers can be specified directly in the odbc.ini configuration file, as described in Configuring the odbc.ini File on page 11.

The odbcinst.ini file is divided into the following sections:

• [ODBC Drivers] lists the names of all the installed ODBC drivers.

• A section having the same name as the driver name specified in the [ODBC Drivers] section lists driver attributes and values.

Here is an example odbcinst.ini file for Linux:

[ODBC Drivers]

Simba MongoDB ODBC Driver 32-bit=Installed

Simba MongoDB ODBC Driver 64-bit=Installed

[Simba MongoDB ODBC Driver 32-bit]

Description=Simba MongoDB ODBC Driver (32-bit)

Driver=/opt/simba/mongodbodbc/lib/32/libsimbamongodbodbc32.so

[Simba MongoDB ODBC Driver 64-bit]

Description=Simba MongoDB ODBC Driver (64-bit)

Page 18: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 13

Driver=/opt/simba/mongodbodbc/lib/64/libsimbamongodbodbc64.so

Here is an example odbcinst.ini file for Mac OS X:

[ODBC Drivers]

Simba MongoDB ODBC Driver=Installed

[Simba MongoDB ODBC Driver]

Description=Simba MongoDB ODBC Driver

Driver=/opt/simba/mongodbodbc/lib/universal/libsimbamongodbodbc.dylib

To define a driver:

1. Open the .odbcinst.ini configuration file in a text editor.

2. Add a new entry to the [ODBC Drivers] section. Type the driver name, and then type =Installed

Note: Assign the driver name as the value of the Driver attribute in the data source definition instead of the driver shared library name.

3. In .odbcinst.ini, add a new section having a name matching the driver name you typed in step 2, and then add configuration options to the section based on the sample odbcinst.ini file provided with Simba ODBC Driver with SQL Connector for MongoDB in the Setup directory. Specify configuration options as key-value pairs.

4. Save the .odbcinst.ini configuration file.

Configuring the simba.mongodbodbc.ini File

To configure Simba ODBC Driver with SQL Connector for MongoDB to work with your ODBC driver manager:

1. Open the .simba.mongodbodbc.ini configuration file in a text editor.

2. Edit the DriverManagerEncoding setting. The value usually must be UTF-16 or UTF-32, depending on the ODBC driver manager you use. iODBC uses UTF-32 and unixODBC uses UTF-16. Consult your ODBC Driver Manager documentation for the correct setting to use.

3. Edit the ODBCInstLib setting. The value is the name of the ODBCInst shared library for the ODBC driver manager you use. The configuration file defaults to the shared library for iODBC. In Linux, the shared library name for iODBC is libiodbcinst.so. In Mac OS X, the shared library name for iODBC is libiodbcinst.dylib.

Note: Consult your ODBC driver manager documentation for the correct library to specify. You can specify an absolute or relative filename for the library. If you intend to use the relative filename, then the path to the library must be included in the library path environment variable. In Linux, the library path environment variable is named LD_LIBRARY_PATH. In Mac OS X, the library path environment variable is named DYLD_LIBRARY_PATH.

4. Save the .simba.mongodbodbc.ini configuration file.

Page 19: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 14

Features

SQL Connector The SQL Connector feature of the driver allows applications to use normal SQL queries against MongoDB, translating standard SQL-92 queries into equivalent MongoDB API calls. This allows standard queries that BI tools execute to run against your MongoDB instance.

Data Types The following data types are supported:

• String

• Boolean

• NumberLong

• NumberInt

• NumberDouble

• BinData

• Date

• jstOID

• Object (see below for more information)

• Array (see below for more information)

The following types are not yet supported:

• Code

• CodeWScope

• DBRef

• JSTypeMax

• MinKey

• MaxKey

• RegEx

• Symbol

• Timestamp

Embedded Documents

Embedded documents in MongoDB are represented as nested columns in the Simba ODBC Driver with SQL Connector for MongoDB. For example, consider the following JSON document:

{"contact": {"address": {"street": "1-123Broadway", "city": "Vancouver"}}, "phone": "+12345678"}

The driver identifies the following columns in the document:

Column MongoDB Data Type Data

contact.address.street String 1-123 Broadway

contact.address.city String Vancouver

phone String +12345678

Page 20: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 15

The identified columns will act in the same way as any other column when being mapped to SQL data types or when generalizing data types.

If there are different fields within a document, then only the most general fields will be identified as columns. Consider the following two documents:

{"contact": {"address": {"street": "1-123Broadway", "city": "Vancouver"}}, "phone": "+12345678"}

{"contact": {"address": "22 Cambie, Vancouver"}, "phone": "+87654321"}

In these documents, contact.address is not an embedded document in the second document and hence it will be considered as a String instead of another embedded document. The driver will identify the following columns for the second document:

Column MongoDB Data Type Data

contact.address String • {street: “1-123 Broadway”, city: “Vancouver”}

• 22 Cambie, Vancouver

phone String • +12345678

• +87654321

These columns can be used in a SQL query just like any other column, however they will need to be quoted as they contain the separator character. For example:

SELECT "contact.address", "phone" FROM Contacts

Arrays

Arrays in MongoDB are also represented as nested columns in the Simba ODBC Driver with SQL Connector for MongoDB. Consider the following JSON document using an array:

{"values": ["hello", 1, {"v1": {"v2": "this is an embedded document"}}]}

The driver will identify the following columns:

Column MongoDB Data Type Data

values.0 String Hello

values.1 Double 1.0

values.2.v1.v2 String this is an embedded document

The column names include the index of the item in the array that the column represents, starting with an index of 0. In other words, the first element of the array will use a suffix of “.0”, the second element will use “.1”, and so on.

Page 21: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 16

If there are two fields having the same name where one is an embedded document and the other is an array, then the two fields are not represented as nested. Instead, the data type is generalized to String. In the following example, the field named f is of type String:

{f : {g1 : 1}}

{f : [1, 2, 3]}

These columns will act in the same way as any other column when being mapped to SQL data types or when generalizing data types.

These columns can be used in a SQL query just like any other column, however they will need to be quoted as they contain the separator character. For example:

SELECT "values.0", "values.1", "values.2.v1.v2" FROM Contacts

Authentication Simba ODBC Driver with SQL Connector for MongoDB leverages authentication built into MongoDB. Built-in authentication requires users to supply a user name and password. If your MongoDB instance does not use authentication, then you can disable authentication for the DSN using the Simba MongoDB ODBC Driver Setup dialog.

For details on using authentication when installing the driver on the Windows operating system, see Creating a Data Source Name on page 2 and Configuring Advanced Options on page 3. For details on Linux and Mac OS X installations, see the section Configuring ODBC Connections for Linux and Mac OS X on page 10.

Catalog Support Simba ODBC Driver with SQL Connector for MongoDB supports catalogs by using the name of the MongoDB database as the catalog, allowing the driver to work easily with various ODBC applications.

Write-back Simba ODBC Driver with SQL Connector for MongoDB supports Data Manipulation Language (DML) statements such as INSERT, UPDATE and DELETE statements. These statements expose standard SQL-92 behavior. The driver does not execute the DML statements atomically, as MongoDB does not have transaction support. However, MongoDB guarantees atomic update on a single row and so does the driver. If an UPDATE/DELETE statement affects multiple rows and an error occurs in one of them, then the driver returns an error, but the rows that are already updated will remain so. Which means, for an UPDATE/DELETE statement, some rows may be updated successfully and the driver may return an error for the rest. Some special cases with DML statements are described in more detail below.

Page 22: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 17

INSERT

Each row in MongoDB needs to have a unique ID represented by the “_id” column. If not provided during insertion, MongoDB auto-generates a unique ID for each row. The “_id” field is exposed as a valid column in MongoDB ODBC Driver and can be auto-generated when issuing INSERT statements through the driver. For example, consider the following table:

_id sample_column

"517024D6CC79814E3FEBD352" 1

"5170ED77E49CC93A918DE316" 2

To insert a document with auto-generated value for “_id” (data type: jstOID), issue the following command:

INSERT INTO sample_table_1(sample_column) VALUES(3)

After the insertion, the table would look like as below:

_id sample_column

"517024D6CC79814E3FEBD352" 1

"5170ED77E49CC93A918DE316" 2

"51710FFCE49CC93A918DE322" 3

The value for the “_id” column can also be inserted using the INSERT statements, as in the following examples:

INSERT INTO sample_table_2(_id, sample_column) VALUES(1,1)

INSERT INTO sample_table_2 VALUES(1,1)

UPDATE

When updating rows, special care needs to be taken to avoid duplicate values for the “_id” column. As mentioned before, “_id” needs to be unique across all rows. When an UPDATE statement tries to set a value for the “_id” column and matches multiple rows, only one of the rows is updated with the new values, and the driver return an error for the remaining rows. UPDATE is not executed atomically.

DELETE

Currently, the driver considers a table valid as long as the table contains some data. If a table is completely empty, then the driver is not able to access the table. Consider the following example:

DELETE FROM sample_table_3

The command removes all data from sample_table_3. Therefore, sample_table_3 is invalid. Any users attempting to access the table receive an error.

Page 23: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 18

Supported Data Types for DML

Currently, Simba ODBC Driver with SQL Connector for MongoDB supports only the following data types in DML statements:

• String

• Boolean

• NumberLong

• NumberInt

• NumberDouble

• BinData

• Date

• Object

• Array

The driver does not yet support inserting/updating values for the jstOID (the ObjectId data type).

Also, the data provided in DML statements should match the existing column data types. For example, a String value cannot be inserted/set in a column having NumberInt data type.

Contact Us If you have difficulty using the driver, please contact our Technical Support staff. We welcome your questions, comments and feature requests.

Technical Support is available Monday to Friday from 8 a.m. to 5 p.m. Pacific Time.

Important: To help us assist you, prior to contacting Technical Support please prepare a detailed summary of the client and server environment including operating system version, patch level and configuration.

You can contact Technical Support via:

• E-mail: [email protected]

• Web site: www.simba.com

• Telephone: (604) 633-0008 Extension 3

• Fax: (604) 633-0004

You can also follow us on Twitter @SimbaTech

Page 24: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 19

Appendix: Driver Configuration Options Table 1 lists advanced configuration settings available in Simba ODBC Driver with SQL Connector for MongoDB.

You can configure advanced options using the following:

• Data Source Name

• Database connection string

Field Label (Key) Default Value Description

Rows fetched per block (RowsFetchedPerBlock)

4096 The maximum number of rows that a query returns at a time

Nested Column Separator (NestedColumnSeparator)

. (Period) The separator to use with nested columns (for embedded documents and arrays). The separator can be single or multiple characters in length. Note: The driver assumes that the separator string would never occur in column names. MongoDB uses the period separator by default.

Rows to Scan (SchemaDetectSampleSize)

100 The number of rows to sample when detecting schema for a table

Read Preference (ReadPreference)

primary The Read Preference option defines how to route read operations to the members of a replica set.

Use SQL_WVARCHAR for String data type (UseSqlWVarchar)

Clear (0) When selected, the MongoDB String type is mapped to SQL_WVARCHAR instead of SQL_VARCHAR. The default value (0) causes the String type to be mapped to SQL_VARCHAR.

Enable authentication (EnableAuthentication)

Clear (0) Enable user/password authentication during connection. The default value (0) disables authentication.

Page 25: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 20

Field Label (Key) Default Value Description

Enable metadata caching (CacheMetadata)

Selected (1) Simba ODBC Driver with SQL Connector for MongoDB dynamically detects the database schema as needed in the process of connecting to a MongoDB database. By default, the driver stores the metadata for reuse. When you disable metadata caching, the driver regenerates the metadata every time the driver accesses the database. If you disable metadata caching, then the driver continues to save schema definitions you set using the Schema Definition dialog. For details on using the Schema Definition dialog, see Defining the Schema on page 5. Important: Caching metadata is useful when defining the schema for your MongoDB database. When the schema is defined, disable metadata caching in your production environment.

Omit default NULL columns on insert (OmitColumns)

Selected (1) This option affects the INSERT operations only. When selected (1), no null values (whether explicitly provided or not) are written to the columns of a table. When clear (0), explicitly provided null values are written to columns as specified, but no default null value is inserted.

Truncate documents larger than 16MB (TruncateDocument)

Clear (0) When clear (0), the driver rejects any document that is greater than 16MB in size. When selected (1), the driver truncates any document that is greater than 16MB in size.

Enable reading/writing as JSON document (UseJSONColumn)

Clear (0) When enabled (1), the driver reports a special column named documentAsJSON that retrieves or stores whole documents as JSON formatted strings. Note: See also the DocumentAsJSON driver configuration option.

String Column Lengths: Standard (DefaultStringColumnLength)

255 The default string column length to use. MongoDB does not provide the length for String columns in its column metadata. The option allows you to tune the length of String columns.

Page 26: Simba ODBC Driver with SQL Connector for MongoDB ... · accessing the MongoDB database. 12. To configure advanced driver options, click the Advanced Options button. For details, see

Simba ODBC Driver with SQL Connector for MongoDB Installation and Configuration Guide

www. s imba .com 21

Field Label (Key) Default Value Description

String Column Lengths: Container (DefaultContainerColumnLength)

511 The default column length to use with containers (arrays and objects) in MongoDB

String Column Lengths: DocumentAsJSON (DefaultJSONColumnLength)

1023 The default column length to use with documentAsJSON fields. Note: See also the Enable reading/writing as JSON document driver configuration option.

Enable updating multiple rows (UpdateMultipleRows)

Clear (0) When the option is disabled (0), then UPDATE statements update one row only even if multiple rows match the filters. When enabled (1), then all rows that match the filters are updated.

Upsert on update (UpsertOnUpdate)

Clear (0) When selected (1), the driver runs the UPDATE operations with the UPSERT flag as true in MongoDB. When UPSERT is true, and no row matches the filters in an UPDATE operation, then the driver inserts a new row in the table. When clear (0), the driver runs the UPDATE operations with the UPSERT flag as false.

Get Metadata From (LocalMetadataFile)

Clear When clear, then the driver loads metadata from the collection in the database named Mersenne_Collection_Metadata. When set to a file path, then the driver loads metadata from the local file specified in the file path. The metadata in the local file needs to be in a predefined JSON format.

Table 1 Advanced Configuration Options