Database Reference
In-Depth Information
chunkWriter);
}
Everything in this code listing should be familiar: The polling loop that waits
for a job to complete is similar to the Python listing in Chapter 7, “Running
Queries.” Writing the results to the spreadsheet uses the same objects that
you saw earlier when setting the project ID property.
Running this script is easy (especially when compared to the setup steps).
First, write the query you intend to run in any range of cells. With those cells
selected, execute Run Query from the BigQuery menu. (If this menu item
isn't there, you might need to reload the page because it updates only when
you open the spreadsheet.) The script then runs your query, downloads the
results one page at a time, and writes the results to a Query Results sheet. If
the destination sheet didn't exist, it will be created; otherwise that sheet will
be reset.
This example grazed only the surface of the kinds of things that you can do in
Apps Script, but hopefully it whet your appetite. For those of you who don't
have the luxury of using Google Spreadsheets, the next section describes
using BigQuery from Excel.
BigQuery Queries in Microsoft Excel
It is surprising (or perhaps terrifying) to realize how much of the world
runs on Excel spreadsheets. During the financial crisis in 2008, there were
stories about traders who managed multibillion dollar trading strategies
from a single Excel spreadsheet with no backup. A coding error in an Excel
spreadsheet created by an economist led to numerous national governments
choosing policies that may have been economically unsound. Excel is an
extremely powerful tool for making sense of your data, if you use it wisely.
Excel has built-in support for connecting to outside data sources. It can
connect to databases via ODBC, import files from a myriad of other sources,
and run queries on the web. The BigQuery team built a custom AppEngine
app that exposes the BigQuery query API in a manner that can integrate
with Excel without requiring custom macros or client-installed software.
This section walks you through setting up access and querying your
BigQuery data from an Excel spreadsheet. Although some of the steps or
menu items involved may be different between Mac and Windows versions,
Search WWH ::




Custom Search