Main Content

PostgreSQL ODBC for macOS

This tutorial shows how to set up a data source and connect to a PostgreSQL database using the MATLAB® command line on the Apple macOS platform PostgreSQL ODBC driver that comes with MATLAB.

Step 1. Verify the driver manager installation.

To create a data source on your Mac computer using the PostgreSQL ODBC driver, you need the unixODBC driver manager. You can download and install the unixODBC driver manager from Homebrew:

Step 2. Set up the data source.

Set up the data source by creating the file ~/.odbc.ini (if it does not exist) and by adding the data source information or appending it at the end of the file. This example assumes that you are connecting to a database server dbtb10, the port number is 5432, toy_store is the database name, and MATLAB is installed at the location /Applications/

Description=Connect to PostgreSQL

Step 3. Connect using the command line.

Use the command line to make the connection.

conn = odbc("postgresql-server","dbdev","matlab");

See Also


Related Topics