Using the CData ODBC Driver for Paylocity in PyCharm

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Paylocity ODBC Driver

The Paylocity ODBC Driver is a powerful tool that allows you to connect with live data from Paylocity, directly from any applications that support ODBC connectivity.

Access Paylocity data like you would a database - read, write, and update Paylocity FALSE, etc. through a standard ODBC Driver interface.



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

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 Paylocity 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 Paylocity 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 Paylocity

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.

Set the following to establish a connection to Paylocity:

  • RSAPublicKey: Set this to the RSA Key associated with your Paylocity, if the RSA Encryption is enabled in the Paylocity account.

    This property is required for executing Insert and Update statements, and it is not required if the feature is disabled.

  • UseSandbox: Set to true if you are using sandbox account.
  • CustomFieldsCategory: Set this to the Customfields category. This is required when IncludeCustomFields is set to true. The default value for this property is PayrollAndHR.
  • Key: The AES symmetric key(base 64 encoded) encrypted with the Paylocity Public Key. It is the key used to encrypt the content.

    Paylocity will decrypt the AES key using RSA decryption.
    It is an optional property if the IV value not provided, The driver will generate a key internally.

  • IV: The AES IV (base 64 encoded) used when encrypting the content. It is an optional property if the Key value not provided, The driver will generate an IV internally.

Connect Using OAuth Authentication

You must use OAuth to authenticate with Paylocity. OAuth requires the authenticating user to interact with Paylocity using the browser. For more information, refer to the OAuth section in the Help documentation.

The Pay Entry API

The Pay Entry API is completely separate from the rest of the Paylocity API. It uses a separate Client ID and Secret, and must be explicitly requested from Paylocity for access to be granted for an account. The Pay Entry API allows you to automatically submit payroll information for individual employees, and little else. Due to the extremely limited nature of what is offered by the Pay Entry API, we have elected not to give it a separate schema, but it may be enabled via the UsePayEntryAPI connection property.

Please be aware that when setting UsePayEntryAPI to true, you may only use the CreatePayEntryImportBatch & MergePayEntryImportBatchgtable stored procedures, the InputTimeEntry table, and the OAuth stored procedures. Attempts to use other features of the product will result in an error. You must also store your OAuthAccessToken separately, which often means setting a different OAuthSettingsLocation when using this connection property.

Below is the syntax for a DSN:

[CData Paylocity Source] Driver = CData ODBC Driver for Paylocity Description = My Description OAuthClientID = YourClientId OAuthClientSecret = YourClientSecret RSAPublicKey = YourRSAPubKey Key = YourKey IV = YourIV

Execute SQL to Paylocity

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 Paylocity};OAuthClientID = YourClientId;OAuthClientSecret = YourClientSecret;RSAPublicKey = YourRSAPubKey;Key = YourKey;IV = YourIV;') cursor = cnxn.cursor() cursor.execute("SELECT FirstName, LastName FROM Employee WHERE EmployeeId = '1234'") rows = cursor.fetchall() for row in rows: print(row.FirstName, row.LastName)

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