Using the CData ODBC Driver for FedEx in PyCharm

Connect to FedEx as an ODBC data source in PyCharm using the CData ODBC Driver for FedEx.

The CData ODBC Drivers can be used in any environment that supports loading an ODBC Driver. In this tutorial we will explore using the CData ODBC Driver for FedEx from within PyCharm. Included are steps for adding the CData ODBC Driver as a data source, as well as basic PyCharm code to query the data source and display results.

To begin, this tutorial will assume that you have already installed the CData ODBC Driver for FedEx as well as PyCharm.

Add Pyodbc to the Project

Follow the steps below to add the pyodbc module to your project.

  1. Click File -> Settings to open the project settings window.
  2. Click Project Interpreter from the Project: YourProjectName menu.
  3. To add pyodbc, click the + button and enter pyodbc.
  4. Click Install Package to install pyodbc.

Connect to FedEx

You can now connect with an ODBC connection string or a DSN. See the Getting Started section in the CData driver documentation for a guide to creating a DSN on your OS.

There are five pieces of information needed in order to authenticate its actions with the FedEx service. This information is below.

  • Server: This controls the URL where the requests should be sent. Common testing options for this are: "", "", "", and ""
  • DeveloperKey: This is the identifier part of the authentication key for the sender's identity. This value will be provided to you by FedEx after registration.
  • Password: This is the secret part of the authentication key for the sender's identity. This value will be provided to you by FedEx after registration.
  • AccountNumber: This valid 9-digit FedEx account number is used for logging into the FedEx server.
  • MeterNumber: This value is used for submitting requests to FedEx. This value will be provided to you by FedEx after registration.
  • PrintLabelLocation: This property is required if one intends to use the GenerateLabels or GenerateReturnLabels stored procedures. This should be set to the folder location where generated labels should be stored.

The Cache Database

Many of the useful tasks available from FedEx require a lot of data. To ensure this data is easy to input and recall later, utilizes a cache database to make these requests. You must set the cache connection properties:

  • CacheProvider: The specific database you are using to cache with. For example, org.sqlite.JDBC.
  • CacheConnection: The connection string to be passed to the cache provider. For example, jdbc:sqlite:C:\users\username\documents\fedexcache.db

Below is the syntax for a DSN:

[CData FedEx Source] Driver = CData ODBC Driver for FedEx Description = My Description Server = '' DeveloperKey = 'alsdkfjpqoewiru' Password = 'zxczxqqtyiuowkdlkn' AccountNumber = '110371337' MeterNumber = '240134349' PrintLabelLocation = 'C:\users\username\documents\mylabels' CacheProvider = 'org.sqlite.JDBC' CacheConnection = 'jdbc:sqlite:C:\users\username\documents\fedexcache.db'

Execute SQL to FedEx

Instantiate a Cursor and use the execute method of the Cursor class to execute any SQL statement.

import pyodbc cnxn = pyodbc.connect('DRIVER={CData ODBC Driver for FedEx};Server = '';DeveloperKey = 'alsdkfjpqoewiru';Password = 'zxczxqqtyiuowkdlkn';AccountNumber = '110371337';MeterNumber = '240134349'; PrintLabelLocation = 'C:\users\username\documents\mylabels';CacheProvider = 'org.sqlite.JDBC';CacheConnection = 'jdbc:sqlite:C:\users\username\documents\fedexcache.db';') cursor = cnxn.cursor() cursor.execute("SELECT FirstName, Phone FROM Senders WHERE SenderID = 'ab26f704-5edf-4a9f-9e4c-25'") rows = cursor.fetchall() for row in rows: print(row.FirstName, row.Phone)

After connecting to FedEx in PyCharm using the CData ODBC Driver, you will be able to build Python apps with access to FedEx data as if it were a standard database. If you have any questions, comments, or feedback regarding this tutorial, please contact us at