SlideShare a Scribd company logo
1 of 40
Download to read offline
● 專案開通:https://sites.google.com/a/mitac.com.tw/google-cloud-platform/getting-start
● Billing Enable:https://sites.google.com/a/mitac.com.tw/google-cloud-platform/getting-
start/enable-billing
● 安裝Google Cloud SDK:
○ Windows: https://sites.google.com/a/mitac.com.tw/google-cloud-platform/getting-
start/windows-install-google-cloud-sdk
○ Others: https://developers.google.com/cloud/sdk/
● 18 : 45 - 19 : 00 報到
● 19 : 00 - 19 : 30 當 BigQuery 碰上 Node.js
● 19 : 30 - 19 : 40 休息
● 19 : 40 - 21 : 00 BigQuery 資料上傳實作
準備...
基地台名稱 - MiTAC Guest
連線帳號 - gcp
連線密碼 - mitacmitac
http://goo.gl/32E4LZ
Simon @ MiCloud
We are….
http://opennodes.arecord.us
今天講的是.... Google BigQuery
今天用的是.... Node.js
今天要做的是...
Tools
Req?
Web
App
Service
時代不同,面對資料的態度也不同...
翟本喬:
● 存得起來的,叫做Storage (儲存)
● 看得到的,叫做Data (資料)
● 看得懂的,叫做Information (資訊)
● 用得出來的,才能夠叫做Intelligent (智慧)
沒有不該儲存的資料...
● POS data
● Log data
● User behavior
● Data Warehouse
● Transactions
例如: 看似無用的Log...
WHO DO WHATWHEN Questions...
所以... 我們需要的是
● 一個存取的方式
● 越簡單越好...
● 輕量...
● 快速...
天下武功,唯快不破...
Tools
Auth
Req?
Web
App
Service
Authenticate with Oauth2.0
$ npm search oauth
google-api-utility模組開發歷程
● 透過初始化設定之後,即可
以直接進行api呼叫動作
○ 設定檔抽離
○ 結合request模組進行api調用
Google Service Account
web server application
service account
v.s.
Service Owner在Google的設定
Prepare Authentications
$ openssl pkcs12 -in privatekey.p12 -out privatekey.pem -nocerts
$ openssl rsa -in privatekey.pem -out key.pem
Generate key.pem
$ openssl pkcs12 -in privatekey.p12 -nodes -nocerts > key.pem
or
google-api-utility module
基本資訊
● https://github.com/peihsinsu/google-api-utility
安裝
● npm install google-api-utility
操作
● apiutil.init(config)
● apiutil.request(options, callback)
var auth = require('google-api-utility')
auth.init({
scope: 'https://www.googleapis.com/auth/bigquery https://www.googleapis.
com/auth/cloud-platform',
client_secret: '/path-to-client_secret.json',
key_pem: '/path-to-key.pem'
});
使用範例 - 初始化
此處需要綁定所欲呼叫的 API相關授
權之Scope位置
設定client_secret.json與相關pem檔
案位置,供jwt運算使用
使用範例 - 呼叫BigQuery
var request = auth.request;
var bqurl = 'https://www.googleapis.com/bigquery/v2/projects/%s/datasets';
request({
url: util.format(bqurl, project),
method: 'GET'
}, function(err, req, doc){
// implements
});
結合原request模組之function,供api呼叫使用
同原request模組操作方式
Tools
Auth
Req?
API
Web
App
Service
Google API Explore https://developers.google.com/apis-explorer/
Google API Explore - Query
Google API Explore - Auth
Operation Scope
Google API Explore - Response
Tools
Auth
Req?
API
SDK Web
App
Service
Idea...
● bigquery.init({...configurations...})
● bigquery.dataset.list(....)
● bigquery.table.load(..., callback)
bigquery module
基本資訊
● https://github.com/peihsinsu/bigquery
安裝
● npm install bigquery
操作
● bigquery.init(config)
● bigquery.[category].[operation](options, callback)
重新包裝 - bigquery模組
var bq = require('bigquery')
, prjId = 'your-bigquery-project-id';
bq.init({
client_secret: '/path/to/client_secret.json',
key_pem: '/path-to-key.pem'
});
bq.dataset.list(prjId, function(e,r,d){
if(e) console.log(e);
console.log(JSON.stringify(d));
}); 操作時,透過bq呼叫job之下的function做操作
bigquery模組可參考:https://github.com/peihsinsu/bigquery
Source Code...
var util = require('util')
, auth = require('google-api-utility')
, request = auth.request
, _ = require('underscore')
exports.init = auth.init;
exports.job = {
token: '',
listds : function(project, cb){
var bqurl = 'https://www.googleapis.com/bigquery/v2/projects/%s/datasets';
request({
url: util.format(bqurl, project),
method: 'GET'
}, cb?cb:auth.commonCb);
}, … (skip)
}
封裝相同類別的api在一起,ex: job相關的放在job物件中
An interest demo...
Google provided node.js tool
Operation with googleapis
var googleapis = require('googleapis');
var jwt = new googleapis.auth.JWT(
'429100748......hv3@developer.gserviceaccount.com',
'/path/to/key.pem',
null,
[
'https://www.googleapis.com/auth/bigquery',
'https://www.googleapis.com/auth/cloud-platform'
]);
Operation with googleapis
jwt.authorize(function(err, tokens) {
googleapis.discover('bigquery', 'v2').execute(function(e,client) {
if(e)
console.log(e);
else
client.bigquery.datasets.list(param).withAuthClient(jwt).execute(function(err, response) {
if(err) console.log(err);
console.log(JSON.stringify(response));
});
});
});
Full Code
http://goo.gl/LD4RN4

More Related Content

Similar to Big query meet node.js

云数据库与云函数.pptx
云数据库与云函数.pptx云数据库与云函数.pptx
云数据库与云函数.pptxJianHuang78
 
Google雲端 第一章準備篇
Google雲端 第一章準備篇Google雲端 第一章準備篇
Google雲端 第一章準備篇gracebrainyu
 
建構金融機構SaaS服務之探討-以Google App Engine為例
建構金融機構SaaS服務之探討-以Google App Engine為例建構金融機構SaaS服務之探討-以Google App Engine為例
建構金融機構SaaS服務之探討-以Google App Engine為例Toomore
 
twMVC#33玩轉 Azure 彈性部署
twMVC#33玩轉 Azure 彈性部署twMVC#33玩轉 Azure 彈性部署
twMVC#33玩轉 Azure 彈性部署twMVC
 
大鱼架构演进
大鱼架构演进大鱼架构演进
大鱼架构演进Jun Liu
 
HKPC 行業專題培訓講座 - 雲計算 在零售業 (I) 基礎篇
HKPC 行業專題培訓講座 - 雲計算 在零售業 (I) 基礎篇HKPC 行業專題培訓講座 - 雲計算 在零售業 (I) 基礎篇
HKPC 行業專題培訓講座 - 雲計算 在零售業 (I) 基礎篇Dennis. Lee
 
中国云计算发展之道
中国云计算发展之道中国云计算发展之道
中国云计算发展之道raisinli
 
Web rtc和webstorage技术讲解
Web rtc和webstorage技术讲解Web rtc和webstorage技术讲解
Web rtc和webstorage技术讲解吴 晓兰
 
前端也能變全端
前端也能變全端前端也能變全端
前端也能變全端ericpi Bi
 
使用Javascript及HTML5打造協同運作系統
使用Javascript及HTML5打造協同運作系統使用Javascript及HTML5打造協同運作系統
使用Javascript及HTML5打造協同運作系統Hsu Ping Feng
 
北區13校GDSC聯合流會.pdf
北區13校GDSC聯合流會.pdf北區13校GDSC聯合流會.pdf
北區13校GDSC聯合流會.pdfssuserded2d4
 
Using google appengine_final
Using google appengine_finalUsing google appengine_final
Using google appengine_finalWei Sun
 
Android消息推送实现 | 友盟 徐仙明
Android消息推送实现 | 友盟 徐仙明 Android消息推送实现 | 友盟 徐仙明
Android消息推送实现 | 友盟 徐仙明 imShining @DevCamp
 
《云计算入门指南》
《云计算入门指南》《云计算入门指南》
《云计算入门指南》wiit
 
[Presales Training]83 演讲 在3 d体验平台中建设全生命周期数字化建筑工程
[Presales Training]83 演讲   在3 d体验平台中建设全生命周期数字化建筑工程[Presales Training]83 演讲   在3 d体验平台中建设全生命周期数字化建筑工程
[Presales Training]83 演讲 在3 d体验平台中建设全生命周期数字化建筑工程Jimmy Chang
 
如何與 Git 優雅地在樹上唱歌
如何與 Git 優雅地在樹上唱歌如何與 Git 優雅地在樹上唱歌
如何與 Git 優雅地在樹上唱歌Mu Chun Wang
 
網路行銷--創業零成本教學5--銷售頁篇
網路行銷--創業零成本教學5--銷售頁篇網路行銷--創業零成本教學5--銷售頁篇
網路行銷--創業零成本教學5--銷售頁篇sweety1110
 
容器與 Gitlab CI 應用
容器與 Gitlab CI 應用容器與 Gitlab CI 應用
容器與 Gitlab CI 應用Philip Zheng
 
地理資訊產業國際發展趨勢
地理資訊產業國際發展趨勢地理資訊產業國際發展趨勢
地理資訊產業國際發展趨勢俤 銳
 

Similar to Big query meet node.js (20)

云数据库与云函数.pptx
云数据库与云函数.pptx云数据库与云函数.pptx
云数据库与云函数.pptx
 
Google雲端 第一章準備篇
Google雲端 第一章準備篇Google雲端 第一章準備篇
Google雲端 第一章準備篇
 
建構金融機構SaaS服務之探討-以Google App Engine為例
建構金融機構SaaS服務之探討-以Google App Engine為例建構金融機構SaaS服務之探討-以Google App Engine為例
建構金融機構SaaS服務之探討-以Google App Engine為例
 
twMVC#33玩轉 Azure 彈性部署
twMVC#33玩轉 Azure 彈性部署twMVC#33玩轉 Azure 彈性部署
twMVC#33玩轉 Azure 彈性部署
 
大鱼架构演进
大鱼架构演进大鱼架构演进
大鱼架构演进
 
HKPC 行業專題培訓講座 - 雲計算 在零售業 (I) 基礎篇
HKPC 行業專題培訓講座 - 雲計算 在零售業 (I) 基礎篇HKPC 行業專題培訓講座 - 雲計算 在零售業 (I) 基礎篇
HKPC 行業專題培訓講座 - 雲計算 在零售業 (I) 基礎篇
 
中国云计算发展之道
中国云计算发展之道中国云计算发展之道
中国云计算发展之道
 
3 Bluemix-LoRa application-IBM
3 Bluemix-LoRa application-IBM3 Bluemix-LoRa application-IBM
3 Bluemix-LoRa application-IBM
 
Web rtc和webstorage技术讲解
Web rtc和webstorage技术讲解Web rtc和webstorage技术讲解
Web rtc和webstorage技术讲解
 
前端也能變全端
前端也能變全端前端也能變全端
前端也能變全端
 
使用Javascript及HTML5打造協同運作系統
使用Javascript及HTML5打造協同運作系統使用Javascript及HTML5打造協同運作系統
使用Javascript及HTML5打造協同運作系統
 
北區13校GDSC聯合流會.pdf
北區13校GDSC聯合流會.pdf北區13校GDSC聯合流會.pdf
北區13校GDSC聯合流會.pdf
 
Using google appengine_final
Using google appengine_finalUsing google appengine_final
Using google appengine_final
 
Android消息推送实现 | 友盟 徐仙明
Android消息推送实现 | 友盟 徐仙明 Android消息推送实现 | 友盟 徐仙明
Android消息推送实现 | 友盟 徐仙明
 
《云计算入门指南》
《云计算入门指南》《云计算入门指南》
《云计算入门指南》
 
[Presales Training]83 演讲 在3 d体验平台中建设全生命周期数字化建筑工程
[Presales Training]83 演讲   在3 d体验平台中建设全生命周期数字化建筑工程[Presales Training]83 演讲   在3 d体验平台中建设全生命周期数字化建筑工程
[Presales Training]83 演讲 在3 d体验平台中建设全生命周期数字化建筑工程
 
如何與 Git 優雅地在樹上唱歌
如何與 Git 優雅地在樹上唱歌如何與 Git 優雅地在樹上唱歌
如何與 Git 優雅地在樹上唱歌
 
網路行銷--創業零成本教學5--銷售頁篇
網路行銷--創業零成本教學5--銷售頁篇網路行銷--創業零成本教學5--銷售頁篇
網路行銷--創業零成本教學5--銷售頁篇
 
容器與 Gitlab CI 應用
容器與 Gitlab CI 應用容器與 Gitlab CI 應用
容器與 Gitlab CI 應用
 
地理資訊產業國際發展趨勢
地理資訊產業國際發展趨勢地理資訊產業國際發展趨勢
地理資訊產業國際發展趨勢
 

More from Simon Su

Kubernetes Basic Operation
Kubernetes Basic OperationKubernetes Basic Operation
Kubernetes Basic OperationSimon Su
 
Google IoT Core 初體驗
Google IoT Core 初體驗Google IoT Core 初體驗
Google IoT Core 初體驗Simon Su
 
JSDC 2017 - 使用google cloud 從雲到端,動手刻個IoT
JSDC 2017 - 使用google cloud 從雲到端,動手刻個IoTJSDC 2017 - 使用google cloud 從雲到端,動手刻個IoT
JSDC 2017 - 使用google cloud 從雲到端,動手刻個IoTSimon Su
 
Google Cloud Platform Special Training
Google Cloud Platform Special TrainingGoogle Cloud Platform Special Training
Google Cloud Platform Special TrainingSimon Su
 
GCE Windows Serial Console Usage Guide
GCE Windows Serial Console Usage GuideGCE Windows Serial Console Usage Guide
GCE Windows Serial Console Usage GuideSimon Su
 
Try Cloud Spanner
Try Cloud SpannerTry Cloud Spanner
Try Cloud SpannerSimon Su
 
Google Cloud Monitoring
Google Cloud MonitoringGoogle Cloud Monitoring
Google Cloud MonitoringSimon Su
 
Google Cloud Computing compares GCE, GAE and GKE
Google Cloud Computing compares GCE, GAE and GKEGoogle Cloud Computing compares GCE, GAE and GKE
Google Cloud Computing compares GCE, GAE and GKESimon Su
 
JCConf 2016 - Google Dataflow 小試
JCConf 2016 - Google Dataflow 小試JCConf 2016 - Google Dataflow 小試
JCConf 2016 - Google Dataflow 小試Simon Su
 
JCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop LabsJCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop LabsSimon Su
 
GCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow IntroductionGCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow IntroductionSimon Su
 
Brocade - Stingray Application Firewall
Brocade - Stingray Application FirewallBrocade - Stingray Application Firewall
Brocade - Stingray Application FirewallSimon Su
 
使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析
使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析
使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析Simon Su
 
Docker in Action
Docker in ActionDocker in Action
Docker in ActionSimon Su
 
Google I/O 2016 Recap - Google Cloud Platform News Update
Google I/O 2016 Recap - Google Cloud Platform News UpdateGoogle I/O 2016 Recap - Google Cloud Platform News Update
Google I/O 2016 Recap - Google Cloud Platform News UpdateSimon Su
 
IThome DevOps Summit - IoT、docker與DevOps
IThome DevOps Summit - IoT、docker與DevOpsIThome DevOps Summit - IoT、docker與DevOps
IThome DevOps Summit - IoT、docker與DevOpsSimon Su
 
Google Cloud Platform Introduction - 2016Q3
Google Cloud Platform Introduction - 2016Q3Google Cloud Platform Introduction - 2016Q3
Google Cloud Platform Introduction - 2016Q3Simon Su
 
Google I/O Extended 2016 - 台北場活動回顧
Google I/O Extended 2016 - 台北場活動回顧Google I/O Extended 2016 - 台北場活動回顧
Google I/O Extended 2016 - 台北場活動回顧Simon Su
 
GCS - Access Control Lists (中文)
GCS - Access Control Lists (中文)GCS - Access Control Lists (中文)
GCS - Access Control Lists (中文)Simon Su
 
Google Cloud Platform - for Mobile Solutions
Google Cloud Platform - for Mobile SolutionsGoogle Cloud Platform - for Mobile Solutions
Google Cloud Platform - for Mobile SolutionsSimon Su
 

More from Simon Su (20)

Kubernetes Basic Operation
Kubernetes Basic OperationKubernetes Basic Operation
Kubernetes Basic Operation
 
Google IoT Core 初體驗
Google IoT Core 初體驗Google IoT Core 初體驗
Google IoT Core 初體驗
 
JSDC 2017 - 使用google cloud 從雲到端,動手刻個IoT
JSDC 2017 - 使用google cloud 從雲到端,動手刻個IoTJSDC 2017 - 使用google cloud 從雲到端,動手刻個IoT
JSDC 2017 - 使用google cloud 從雲到端,動手刻個IoT
 
Google Cloud Platform Special Training
Google Cloud Platform Special TrainingGoogle Cloud Platform Special Training
Google Cloud Platform Special Training
 
GCE Windows Serial Console Usage Guide
GCE Windows Serial Console Usage GuideGCE Windows Serial Console Usage Guide
GCE Windows Serial Console Usage Guide
 
Try Cloud Spanner
Try Cloud SpannerTry Cloud Spanner
Try Cloud Spanner
 
Google Cloud Monitoring
Google Cloud MonitoringGoogle Cloud Monitoring
Google Cloud Monitoring
 
Google Cloud Computing compares GCE, GAE and GKE
Google Cloud Computing compares GCE, GAE and GKEGoogle Cloud Computing compares GCE, GAE and GKE
Google Cloud Computing compares GCE, GAE and GKE
 
JCConf 2016 - Google Dataflow 小試
JCConf 2016 - Google Dataflow 小試JCConf 2016 - Google Dataflow 小試
JCConf 2016 - Google Dataflow 小試
 
JCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop LabsJCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop Labs
 
GCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow IntroductionGCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow Introduction
 
Brocade - Stingray Application Firewall
Brocade - Stingray Application FirewallBrocade - Stingray Application Firewall
Brocade - Stingray Application Firewall
 
使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析
使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析
使用 Raspberry pi + fluentd + gcp cloud logging, big query 做iot 資料搜集與分析
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
Google I/O 2016 Recap - Google Cloud Platform News Update
Google I/O 2016 Recap - Google Cloud Platform News UpdateGoogle I/O 2016 Recap - Google Cloud Platform News Update
Google I/O 2016 Recap - Google Cloud Platform News Update
 
IThome DevOps Summit - IoT、docker與DevOps
IThome DevOps Summit - IoT、docker與DevOpsIThome DevOps Summit - IoT、docker與DevOps
IThome DevOps Summit - IoT、docker與DevOps
 
Google Cloud Platform Introduction - 2016Q3
Google Cloud Platform Introduction - 2016Q3Google Cloud Platform Introduction - 2016Q3
Google Cloud Platform Introduction - 2016Q3
 
Google I/O Extended 2016 - 台北場活動回顧
Google I/O Extended 2016 - 台北場活動回顧Google I/O Extended 2016 - 台北場活動回顧
Google I/O Extended 2016 - 台北場活動回顧
 
GCS - Access Control Lists (中文)
GCS - Access Control Lists (中文)GCS - Access Control Lists (中文)
GCS - Access Control Lists (中文)
 
Google Cloud Platform - for Mobile Solutions
Google Cloud Platform - for Mobile SolutionsGoogle Cloud Platform - for Mobile Solutions
Google Cloud Platform - for Mobile Solutions
 

Big query meet node.js