Query USPS Data in MySQL Workbench

Execute MySQL queries against live USPS data from MySQL Workbench.

You can use the SQL Gateway from the ODBC Driver for USPS to query USPS data through a MySQL interface. Follow the procedure below to start the MySQL remoting service of the SQL Gateway and work with live USPS data in MySQL Workbench.

Connect to USPS Data

If you have not already done so, provide values for the required connection properties in the data source name (DSN). You can use the built-in Microsoft ODBC Data Source Administrator to configure the DSN. This is also the last step of the driver installation. See the "Getting Started" chapter in the help documentation for a guide to using the Microsoft ODBC Data Source Administrator to create and configure a DSN.

To authenticate with USPS, set the following connection properties.

  • PostageProvider: The postage provider to use to process requests. Available options are ENDICIA and STAMPS. If unspecified, this property will default to ENDICIA.
  • UseSandbox: This controls whether live or test requests are sent to the production or sandbox servers. If set to true, the Password, AccountNumber, and StampsUserId properties are ignored.
  • StampsUserId: This value is used for logging into authentication to the Stamps servers. This value is not applicable for Endicia and is optional if UseSandbox is true.
  • Password: This value is used for logging into Endicia and Stamps servers. If the postage provider is Endicia, this will be the pass phrase associated with your postage account. It is optional if UseSandbox is true.
  • AccountNumber: The shipper's account number. It is optional if UseSandbox is true.
  • PrintLabelLocation: This property is required 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 task available from USPS require a lot of data. To ensure this data is easy to input and recall later, utilize a cache database to make requests. Set the cache connection properties in order to use the cache:

  • CacheLocation: The path to the cache location, for which a connection will be configured with the default cache provider. For example, C:\users\username\documents\uspscache

As an alternative to CacheLocation, set the combination of CacheConnection and CacheProvider to configure a cache connection using a provider separate from the default.

Configure the SQL Gateway

See the SQL Gateway Overview to set up connectivity to USPS data as a virtual MySQL database. You will configure a MySQL remoting service that listens for MySQL requests from clients. The service can be configured in the SQL Gateway UI.

Query USPS from MySQL Workbench

The steps below outline connecting to the virtual USPS database created in the SQL Gateway from MySQL Workbench and issuing basic queries to work with live USPS data.

Connect to USPS through the SQL Gateway

  1. In MySQL Workbench, click to add a new MySQL connection.
  2. Name the connection (CData SQL Gateway for USPS).
  3. Set the Hostname, Port, and Username parameters to connect to the SQL Gateway.
  4. Click Store in Vault to set and store the password.
  5. Click Test Connection to ensure the connection is configured properly and click OK.

Query USPS Data

  1. Open the connection you just created (CData SQL Gateway for USPS).
  2. Click File -> New Query Tab.
  3. Write a SQL query to retrieve USPS data, like SELECT * FROM `CData USPS Sys`.Senders;

With access to live USPS data from MySQL Workbench, you can easily query and update USPS, just like you would a MySQL database. Get started now with a free, 30-day trial of the CData ODBC Driver for USPS and the CData SQL Gateway.