简体   繁体   English

如何从BigQuery检索数据并将数据插入到mySQL?

[英]How to retrieve data from BigQuery and insert the data to mySQL?

I'm trying to write a batch file which can retrieve specific data from Google BigQuery and then insert these data to mySQL. 我正在尝试编写一个批处理文件,该文件可以从Google BigQuery检索特定数据,然后将这些数据插入到mySQL中。

The language for batch server is Java and the build tool is Ant. 批处理服务器的语言是Java,而构建工具是Ant。

As Iñigo mentioned, you can read the data from BigQuery with the BigQuery Java client library . Iñigo所述,您可以使用BigQuery Java客户端库从BigQuery读取数据。 This would be the easiest approach. 这将是最简单的方法。 You have 2 options here: 您在这里有2个选项:

a.Create a query job to get the result set of a SQL query, parse the result and write it to MySQL. 创建查询作业以获取SQL查询的结果集,解析结果并将其写入MySQL。 For this approach you can use: 对于这种方法,您可以使用:

  1. The “Job create” method to create a query job (see an example in the link). “作业创建”方法可创建查询作业(请参见链接中的示例)。
  2. The “getJob” method to get the status of the asynchronous job. “ getJob”方法获取异步作业的状态。
  3. The “getQuery” method results method to get the result set. “ getQuery”方法的结果方法可获取结果集。

b.Create an export job , which will export the data of a BigQuery table to a file in Cloud Storage, then, download the file from Cloud Storage and write the data to MySQL. b。创建一个导出作业 ,它将BigQuery表的数据导出到Cloud Storage中的文件,然后从Cloud Storage下载文件并将数据写入MySQL。 Note this method will be more difficult if you are not familiar to Google Cloud Platform, since you'll need to create a Cloud Storage bucket and interact with the Cloud Storage Java library . 请注意,如果您不熟悉Google Cloud Platform,则此方法将更加困难,因为您需要创建一个Cloud Storage存储桶并与Cloud Storage Java库进行交互。

To write the data to MySQL you'll need to use a Java Connector like this one . 将数据写入到MySQL,你需要使用一个Java Connector像这一个

Hope this points you into the right direction. 希望这可以为您指明正确的方向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM