We are proud to share our inclusion in the 2024 Gartner Magic Quadrant for Data Integration Tools. We believe this recognition reflects the differentiated business outcomes CData delivers to our customers.
Get the Report →How to Build an ETL App for Reckon Accounts Hosted Data in Python with CData
Create ETL applications and real-time data pipelines for Reckon Accounts Hosted data in Python with petl.
The rich ecosystem of Python modules lets you get to work quickly and integrate your systems more effectively. With the CData Python Connector for Reckon Accounts Hosted and the petl framework, you can build Reckon Accounts Hosted-connected applications and pipelines for extracting, transforming, and loading Reckon Accounts Hosted data. This article shows how to connect to Reckon Accounts Hosted with the CData Python Connector and use petl and pandas to extract, transform, and load Reckon Accounts Hosted data.
With built-in, optimized data processing, the CData Python Connector offers unmatched performance for interacting with live Reckon Accounts Hosted data in Python. When you issue complex SQL queries from Reckon Accounts Hosted, the driver pushes supported SQL operations, like filters and aggregations, directly to Reckon Accounts Hosted and utilizes the embedded SQL engine to process unsupported operations client-side (often SQL functions and JOIN operations).
Connecting to Reckon Accounts Hosted Data
Connecting to Reckon Accounts Hosted data looks just like connecting to any relational data source. Create a connection string using the required connection properties. For this article, you will pass the connection string as a parameter to the create_engine function.
The connector makes requests to Reckon Accounts Hosted through OAuth. Specify the following connection properties:
- SubscriptionKey: Required. You get this value when you created your developer account.
- CountryVersion: Defaults to 2021.R2.AU.
- CompanyFile: Required. The path to the company file.
- User: Required. The username of the company file.
- Password: Required. The password of the company file.
- InitiateOAuth: Set this to GETANDREFRESH to let the driver handle access tokens.
- CallbackURL: The redirectURI of your Custom OAuth App.
- OAuthClientId: The client id of your Custom OAuth App.
- OAuthClientSecret: The client secret of your Custom OAuth App.
CData provides an embedded OAuth application that simplifies OAuth desktop authentication. See the Help documentation for information on other OAuth authentication methods (web, headless, etc.), creating custom OAuth applications, and reasons for doing so.
After installing the CData Reckon Accounts Hosted Connector, follow the procedure below to install the other required modules and start accessing Reckon Accounts Hosted through Python objects.
Install Required Modules
Use the pip utility to install the required modules and frameworks:
pip install petl pip install pandas
Build an ETL App for Reckon Accounts Hosted Data in Python
Once the required modules and frameworks are installed, we are ready to build our ETL app. Code snippets follow, but the full source code is available at the end of the article.
First, be sure to import the modules (including the CData Connector) with the following:
import petl as etl import pandas as pd import cdata.reckonaccountshosted as mod
You can now connect with a connection string. Use the connect function for the CData Reckon Accounts Hosted Connector to create a connection for working with Reckon Accounts Hosted data.
cnxn = mod.connect("SubscriptionKey=my_subscription_key;CountryVersion=2021.R2.AU;CompanyFile=Q:/CompanyName.QBW;User=my_user;Password=my_password;CallbackURL=http://localhost:33333;OAuthClientId=my_oauth_client_id;OAuthClientSecret=my_oauth_client_secret;InitiateOAuth=GETANDREFRESH;OAuthSettingsLocation=/PATH/TO/OAuthSettings.txt")")
Create a SQL Statement to Query Reckon Accounts Hosted
Use SQL to create a statement for querying Reckon Accounts Hosted. In this article, we read data from the Accounts entity.
sql = "SELECT Name, Balance FROM Accounts WHERE IsActive = 'true'"
Extract, Transform, and Load the Reckon Accounts Hosted Data
With the query results stored in a DataFrame, we can use petl to extract, transform, and load the Reckon Accounts Hosted data. In this example, we extract Reckon Accounts Hosted data, sort the data by the Balance column, and load the data into a CSV file.
Loading Reckon Accounts Hosted Data into a CSV File
table1 = etl.fromdb(cnxn,sql) table2 = etl.sort(table1,'Balance') etl.tocsv(table2,'accounts_data.csv')
In the following example, we add new rows to the Accounts table.
Adding New Rows to Reckon Accounts Hosted
table1 = [ ['Name','Balance'], ['NewName1','NewBalance1'], ['NewName2','NewBalance2'], ['NewName3','NewBalance3'] ] etl.appenddb(table1, cnxn, 'Accounts')
With the CData Python Connector for Reckon Accounts Hosted, you can work with Reckon Accounts Hosted data just like you would with any database, including direct access to data in ETL packages like petl.
Free Trial & More Information
Download a free, 30-day trial of the CData Python Connector for Reckon Accounts Hosted to start building Python apps and scripts with connectivity to Reckon Accounts Hosted data. Reach out to our Support Team if you have any questions.
Full Source Code
import petl as etl import pandas as pd import cdata.reckonaccountshosted as mod cnxn = mod.connect("SubscriptionKey=my_subscription_key;CountryVersion=2021.R2.AU;CompanyFile=Q:/CompanyName.QBW;User=my_user;Password=my_password;CallbackURL=http://localhost:33333;OAuthClientId=my_oauth_client_id;OAuthClientSecret=my_oauth_client_secret;InitiateOAuth=GETANDREFRESH;OAuthSettingsLocation=/PATH/TO/OAuthSettings.txt")") sql = "SELECT Name, Balance FROM Accounts WHERE IsActive = 'true'" table1 = etl.fromdb(cnxn,sql) table2 = etl.sort(table1,'Balance') etl.tocsv(table2,'accounts_data.csv') table3 = [ ['Name','Balance'], ['NewName1','NewBalance1'], ['NewName2','NewBalance2'], ['NewName3','NewBalance3'] ] etl.appenddb(table3, cnxn, 'Accounts')