719016
719016

Reputation: 10441

Google Cloud bigQuery connect ruby API query to table

I have a software product with a Ruby API that generates a table-like output when queried, and I would like to dynamically connect the output to Google Cloud bigQuery.

Having read the documentation, there is a dynamic connector for Google Sheets, and static ETL connectors to PostgreSQL and other (https://cloud.google.com/blog/big-data/2016/05/bigquery-integrates-with-google-drive).

If I have a ruby query that looks like the one below:

ruby productX-api/ruby/query_table.rb param1 param2

and this produces a table from the query:

field1,field2,field3
foo,bar,bar
xyz,abc,def

What options do I have to connect this to bigQuery?

Upvotes: 1

Views: 487

Answers (1)

LundinCast
LundinCast

Reputation: 9810

There's no built-in connector as you'd like but you can pretty easily load the resulting csv file programmatically by using the Google Cloud client library for Ruby. For example:

require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"
table = dataset.table "my_table"

file = File.open "my_data.csv"
load_job = table.load_job file

More information here for the particular load_job method.

Upvotes: 1

Related Questions