Happy #MapInfoMonday
Most users rely on the native MapInfo tables when they need to store data. These files are easy to work with and quite performant in MapInfo Pro. The latest extended version of the native MapInfo table format can hold massive amounts of data too whereas the older format was limited to 2GB. The native MapInfo tables do have a shortcoming if several users need to edit the table at the same time.
This is where a spatial database could prove helpful. Besides allowing several users to edit the data simultaneously, it also brings also benefits to the table such as access to the data from non-GIS applications and the benefit of using a database with features like security, triggers, views, and more.
In this article and a few to follow, I'll introduce how you can start using data in a database from within MapInfo Pro. In this first article, we will look at connecting to an ODBC database from MapInfo Pro. We will create an ODBC Data Source and use this to connect to the database. In an upcoming article, I will discuss how you can prepare the database to be used from MapInfo Pro and how you can upload spatial data into the database. And finally, we will look at accessing data stored in a database.
Let's get started
What is ODBC?
ODBC - or Open Database Connectivity - is a standard API for accessing databases from applications. The idea behind ODBC is to make it possible to easily change the database used by an application without having the rewrite the logic of the application.
This was done by introducing a translation layer between the application and the database: the ODBC driver. The application "talks" to the ODBC driver which translates the request into a request or query that the database understands. And similarly, the response from the database is passed back to the application in a standard way.
When you start working with databases and ODBC, you need to understand the different terms. First, you have a database. This is also often referred to as a DBMS, a DataBase Management System. Next, there is the ODBC Driver that knows how to talk to a specific database. This driver mostly needs to be installed onto your system. Using this ODBC driver, you can create a data source that basically describes what database to connect to using which ODBC Driver. And finally, you connect to the database using the data source from within your application, in this case, MapInfo Pro.
I think this is also a good spot to mention that MapInfo Pro also uses other ways to connect to specific databases.
For Oracle Spatial, we recommend - or require - you to use Oracle Call Interface, OCI. You can read more about connecting the Oracle Spatial in the MapInfo Pro User Guide in the chapter Creating a Data Source Connection to Oracle.
MapInfo Pro has built-in support for SQLite databases and for GeoPackage databases. You don't need to use ODBC to connect to these.
Read more about ODBC on Wikipedia.
Creating an ODBC Data Source
I'm going to assume that you have 1) MapInfo Pro installed and 2) a database system installed too. In my example, I will use PostgreSQL with PostGIS. The steps would be similar for another database system such as MS SQL Server.
First, you need to download and install the specific PDBC driver for the database system. For PostgreSQL with PostGIS, you can find the drivers here: odbc.postgresql.org. For MS SQL Server, this is a good starting place: Download ODBC Driver for SQL Server.
If you look in the latest Release Notes document, you can find a list of ODBC drivers that MapInfo Pro supports. These are drivers that have been tested with MapInfo Pro. We may also support newer/older versions but we can't be sure as we have tested these. As MapInfo Pro is a 64-bit application, you also need to ensure that you install a 64-bit driver.
These are the supported drivers for MapInfo Pro v2021.1:
- Microsoft Access ODBC (64-bit)
- Microsoft SQL Server 2019
- Microsoft SQL Server 2017
- Microsoft SQL Server 2016
- Microsoft SQL Server 2012 QFE Native Client v11 (64-bit)
- PostgreSQL Unicode and ANSI ODBC driver 13.01 (64-bit)
- FDO toolkit 3.8 (used by SQLite and installed with MapInfo Pro)
- Oracle Instant Client 19.11 (64-bit)
- Microsoft ODBC Driver for SQL Server 17.8
You may also have to reach out to your IT department to get the ODBC driver installed on your system.
Once the ODBC Driver has been installed, it's time to create an ODBC Data Source. You can create this directly from within MapInfo Pro or from the Windows Control Panel. I'll show you how to create it from within MapInfo Pro.
From the Home tab, click on Open Database Table in the Open dropdown.
The dialog Select Data Source now appears.
Connection to a Database using an ODBC Data Source
You can connect to a database system from multiple places in MapInfo Pro.
Above you saw that you can do this from the Open DBMS Table control on in the Open dropdown.
You can also connect to a database from the Open dialog through Open DBMS Connect button in the top right corner of the dialog.
And finally, if you often or always need to connect to a database, you can configure MapInfo Pro to connect to a database through the Startup Preferences dialog.
Click on Set... in the Default DBMS Connection area and select your preferred DBMS Data Source. If you have selected a data source, MapInfo Pro will automatically connect to this database when it starts.
No matter how you have connected to a database, you will afterward be able to locate the open database connections in the Files of Type list in the Open dialog.
------------------------------
Peter Horsbøll Møller
Principal Presales Consultant | Distinguished Engineer
Precisely | Trust in Data
------------------------------