Extend Couchbase Analytics with SQL Server using CData.
This article will guide you through the steps needed to setup the connection from Couchbase Analytics to SQL Server using the CData ODBC driver for Couchbase. More details regarding this driver can be found here. The download comes with a second driver, CData SQL Gateway and its information can be found here.
**Note – for the CData SQL Gateway, this setup requires the enterprise license.
Prerequisites
Couchbase
You will first need a Couchbase Server Enterprise Edition (EE) 6.x cluster with the Data and Analytic services enabled. I am using a single node local install of Couchbase Server EE but the information in this article applies to any Couchbase Server EE cluster.
If you do not have an existing Couchbase Server EE cluster, the following links will get you up and running quickly:
- Download Couchbase Server EE
- Install Couchbase Server EE
- Provision a single-node cluster (NOTE: use the default values for cluster configuration)
SQL Server
Using a windows based platform with the following details:
Couchbase Setup
In Couchbase click on SettingsÂ
Then Sample Buckets
The select the beer-sample checkbox and select Load Sample Data. You can then navigate back to your Buckets and see beer-sample.
Once this is complete, we will need to setup Analytics.
Select Analytics, then create the shadow dataset of beers from the bucket of beer-sample.
1 |
CREATE DATASET beers ON `beer-sample` WHERE `type` = "beer"; |
Click Execute, this will crate the shadow dataset definition.
I want to repeat this step by creating a second shadow dataset with the following definition.
1 |
CREATE DATASET breweries ON `beer-sample` WHERE `type` = "brewery"; |
Next you will want to initialize it by activating the dataset with the following.
1 |
CONNECT LINK Local; |
Click Execute.
You can now test this out within the Analytics dashboard by running something like the following.
1 2 3 |
SELECT COUNT(*) FROM beers UNION ALL SELECT COUNT(*) FROM breweries; |
More about Couchbase Analytics can be found here.
Your setup for Couchbase is complete!
SQL Server Setup
I installed SQL Server Express with all the defaults which can be found here.
Install CData ODBC Driver for Couchbase (Enterprise Edition) to enable SQL Server Linked Server
Setup the ODBC Driver
-
- I set the following parameters
- Data Source Name: CData Couchbase Source
- User: Administrator
- Password:password
- Server: 13.92.234.252
- Analytics Port: 8095
- Verbosity: 5
- Dataverse: Default
- Flatten Arrays: 4
- I set the following parameters
Setup SQL Gateway ODBC driver to configure the TDS Remoting Service
Select run as a service
Configure the service with the following settings:
Configure the Users tab with the following settings:
Now we will want to create a linked server to Couchbase
Now that we have successfully setup the connection between SQL Server and Couchbase, lets try a simple SQL statement written in SQL Server Management Studio that will execute against Couchbase Analytics
1 2 |
SELECT * FROM CB_DEMO.[CData Couchbase Sys].[Couchbase].[beers] |
Next Steps
Try creating a table on SQL Server and inserting data from Couchbase.
Download Couchbase, setup Analytics, and start using SQL Server with your data and see what insights you can gleam. Extend Analytics with other tools using the many Couchbase CData drivers that are at your fingertips.