Connect to WooCommerce as an External Data Source 📦

SQL Server Instance to be Used ?

PolyBase for SQL Server allows you to query external data by using the same Transact-SQL syntax used to query a database table. When paired with the CData ODBC Driver for WooCommerce, you get access to your WooCommerce data directly alongside your SQL Server data. This article walks through creating an external data source and external tables to grant access to live WooCommerce data using T-SQL queries. The CData ODBC drivers offer unmatched performance for interacting with live WooCommerce data using PolyBase due to optimized data processing built into the driver. When you issue complex SQL queries from SQL Server to WooCommerce, the driver pushes down supported SQL operations, like filters and aggregations, directly to WooCommerce and utilizes the embedded SQL engine to process unsupported operations (often SQL functions and JOIN operations) client-side. And with PolyBase, you can also join SQL Server data with WooCommerce data, using a single query to pull data from distributed sources.





































Initial Approach

If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs. To create an external data source in SQL Server using PolyBase, configure a System DSN (CData WooCommerce Sys is created automatically).WooCommerce supports the following authentication methods: one-legged OAuth1.0 Authentication and standard OAuth2.0 Authentication.






















Steps to be followed :-

  • Connecting using one-legged OAuth 1.0 Authentication
  • 1.Consumer Key
  • 2.ConsumerSecret

  • Connecting using WordPress OAuth 2.0 Authentication
  • OAuthClientId
  • OAuthClientSecret
  • CallbackURL
  • InitiateOAuth - Set this to either GETANDREFRESH or REFRESH

Final Approach

  • Creating a Master Encryption Key
  • Execute the following SQL command to create a new master key, 'ENCRYPTION,' to encrypt the credentials for the external data source.


    CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'password';
  • Creating a Credential Database
  • Execute the following SQL command to create credentials for the external data source connected to WooCommerce data.


    CREATE DATABASE SCOPED CREDENTIAL woocommerce_creds WITH IDENTITY = 'username', SECRET = 'password';
  • Create an External Data Source for WooCommerce
  • Execute the following SQL command to create an external data source for WooCommerce with PolyBase, using the DSN and credentials configured earlier.


    CREATE EXTERNAL DATA SOURCE cdata_woocommerce_source WITH ( LOCATION = 'odbc://SERVERNAME[:PORT]', CONNECTION_OPTIONS = 'DSN=CData WooCommerce Sys', -- PUSHDOWN = ON | OFF, CREDENTIAL = woocommerce_creds );







In case of any issues with WooCommerce as an External Data Source : Get in touch

0 Comments