Replicate Multiple NetSuite SuiteAnalytics Accounts via the CData Sync CLI
CData Sync for NetSuite SuiteAnalytics is a stand-alone application that provides solutions for a variety of replication scenarios such as replicating sandbox and production instances into your database. Both Sync for Windows and Sync for Java include a command-line interface (CLI) that makes it easy to manage multiple NetSuite SuiteAnalytics connections. In this article we show how to use the CLI to replicate multiple NetSuite SuiteAnalytics accounts.
Configure NetSuite SuiteAnalytics Connections
You can save connection and email notification settings in an XML configuration file. To replicate multiple NetSuite SuiteAnalytics accounts, use multiple configuration files. Below is an example configuration to replicate NetSuite SuiteAnalytics to SQLite:
Windows
<?xml version="1.0" encoding="UTF-8" ?> <CDataSync> <DatabaseType>SQLite</DatabaseType> <DatabaseProvider>System.Data.SQLite</DatabaseProvider> <ConnectionString>InitiateOAuth=GETANDREFRESH;</ConnectionString> <ReplicateAll>False</ReplicateAll> <NotificationUserName></NotificationUserName> <DatabaseConnectionString>Data Source=C:\my.db</DatabaseConnectionString> <TaskSchedulerStartTime>09:51</TaskSchedulerStartTime> <TaskSchedulerInterval>Never</TaskSchedulerInterval> </CDataSync>
Java
<?xml version="1.0" encoding="UTF-8" ?> <CDataSync> <DatabaseType>SQLite</DatabaseType> <DatabaseProvider>org.sqlite.JDBC</DatabaseProvider> <ConnectionString>InitiateOAuth=GETANDREFRESH;</ConnectionString> <ReplicateAll>False</ReplicateAll> <NotificationUserName></NotificationUserName> <DatabaseConnectionString>Data Source=C:\my.db</DatabaseConnectionString> </CDataSync>
Prerequisites
Before you can connect to NetSuite SuiteAnalytics, you must set up SuiteAnalytics Connect in your NetSuite account:
-
Enable the Connect Service feature.
-
Ensure that your Account Administrator has enabled your Account and Role with the Connect Service feature.
-
Navigate to Setup > Company > Enable Features.
-
Click the Analytics tab and check the SuiteAnalytics Connect box.
-
-
Add the SuiteAnalytics Connect permission to an existing Role.
-
Navigate to Setup > Users/Roles > User Management > Manage Roles.
-
Click Customize next to the name of the role for which you would like to add the SuiteAnalytics Connect permission.
-
Click the Setup tab under the Permissions tab.
-
Add the SuiteAnalytics Connect permission.
-
Click Add and Save.
-
-
Verify the Suite Analytics Connect permissions.
-
Find the Settings portlet on your home page and click Set Up SuiteAnalytics Connect.
-
Click Your Configuration to view your service host and account ID information. These settings map directly to Server and Account ID connection properties.
-
Add the NetSuite SuiteAnalytics Connector
To enable Sync to use data from NetSuite SuiteAnalytics, you first must add the connector, as follows:
-
Open the Connections page of the Sync dashboard.
-
Click Add Connection to open the Select Connectors page.
-
Click the Sources tab and locate the NetSuite SuiteAnalytics row.
-
Click the Configure Connection icon at the end of that row to open the New Connection page. If the Configure Connection icon is not available, click the Download Connector icon to install the NetSuite SuiteAnalytics connector. For more information about installing new connectors, see the Connections section in the Help documentation.
Authenticate to NetSuite SuiteAnalytics
After you add the connector, you need to set the required properties.
-
Connection Name - Enter a connection name of your choice.
-
Server - Enter the value of Service Host you previously found.
-
Account Id - Enter the value of Account Id you previously found.
-
Role Id - Enter the Role ID you previously updated.
-
User - Enter the username that you use to authenticate to your NetSuite account.
-
Password - Enter the password associated with that account.
Configure Queries for Each NetSuite SuiteAnalytics Instance
Sync enables you to control replication with standard SQL. The REPLICATE statement is a high-level command that caches and maintains a table in your database. You can define any SELECT query supported by the NetSuite SuiteAnalytics API. The statement below caches and incrementally updates a table of NetSuite SuiteAnalytics data:
REPLICATE Account;
You can specify a file containing the replication queries you want to use to update a particular database. Separate replication statements with semicolons. The following options are useful if you are replicating multiple NetSuite SuiteAnalytics accounts into the same database:
You can use a different table prefix in the REPLICATE SELECT statement:
REPLICATE PROD_Account SELECT * FROM Account
Alternatively, you can use a different schema:
REPLICATE PROD.Account SELECT * FROM Account
Run Sync
After you have configured the connection strings and replication queries, you can run Sync with the following command-line options:
Windows
SuiteAnalyticsSync.exe -g MyProductionSuiteAnalyticsConfig.xml -f MyProductionSuiteAnalyticsSync.sql
Java
java -Xbootclasspath/p:c:\sqlitejdbc.jar -jar SuiteAnalyticsSync.jar -g MyProductionSuiteAnalyticsConfig.xml -f MyProductionSuiteAnalyticsSync.sql