Sunday, March 27, 2016

Download SalesForce Report in CSV to import into MySQL

I've used Talend Open Studio to import SalesForce report data into MySQL via REST API but it turned out the Analytics API limits up to 2,000 records so now use Python to pull it from CSV and import into MySQL. Here is the code

Sunday, March 6, 2016

How to install Git on a shared host

I've noted here but wanted to post on my blog so I can find it quickly if necessary.

First, make sure gcc is working:
gcc --version

Then update the ~/.bashrc:
export PATH=$HOME/bin:$PATH

source ~/.bashrc

Then install Git:
cd ~/
mkdir src
cd src
wget https://github.com/git/git/archive/v2.7.1.tar.gz
wget https://curl.haxx.se/download/curl-7.47.1.tar.gz
tar -xzvf v2.7.1.tar.gz
tar -xzvf curl-7.47.1.tar.gz
cd git-2.7.1/
make configure
./configure --prefix=$HOME --with-curl=~/src/curl-7.47.1
make
make install

Thursday, March 3, 2016

Access Salesforce REST API from Talend Open Studio

Today I have a task to pull report data from Salesforce REST API into MySQL database. I've used Talend Open Studio to sync daily Salesforce's modules into Postgresql or replicate MS SQL database into Postgresql before so looks like this task is not difficult. It turned out the Salesforce REST API now requires OAuth 2.0, so I googled to find out how to do that and got this http://www.deepinopensource.com/access-apex-rest-api-salesforce-from-talend/ . The problem is this guide's using cURL to get access_token to enter manually into tRESTClient while I need to do it automatically for daily auto-sync.. So I learned more about Talend's components.. (found it's very powerful!). Here is my solution: use one tRESTClient to request an access token first to assign into context variable, then execute another tRESTClient to access Salesforce REST API with that token.

Below are screenshots.


1. Request a token

2. Extract the token from output

3. Assign token into context variable

4. Use that token for REST

5. Because the Salesforce REST output contains special node name that causes invalid parsing so replace it with a common character

6. Extract the JSON data
 7. Save into MySQL database