title | description | author | tags | date_published |
---|---|---|---|---|
Connect to BigQuery from Microsoft Excel using ODBC |
Learn how to use the ODBC drivers for BigQuery to load query results into Microsoft Excel for analysis and visualization. |
tswast |
BigQuery, Excel, ODBC |
2017-01-26 |
Tim Swast | Developer Programs Engineer | Google
Contributed by Google employees.
BigQuery enables standard SQL queries to petabytes of data. But what if software that you depend on doesn't use the BigQuery API? The BigQuery ODBC drivers enable you to connect tools, such as Microsoft Excel, that use the Open Database Connectivity (ODBC) API to BigQuery.
- Installing the ODBC driver for BigQuery
- Configuring the ODBC driver
- Loading query results into Microsoft Excel
This tutorial assumes that you're using the Microsoft Windows operating system.
-
Create a project in the Cloud Console.
-
See the blog post on getting started with the BigQuery free tier or video for more detailed instructions.
-
Install Microsoft Excel 2016 for Windows.
This tutorial uses billable components of Google Cloud, including BigQuery.
Use the Pricing Calculator to estimate the costs for your usage.
The first 1 TB per month of BigQuery queries are free. See the BigQuery pricing documentation for details about on-demand and flat-rate pricing. BigQuery also offers controls to limit your costs.
- Check whether your version of Excel is 32-bit or 64-bit.
- Download the latest version of the ODBC driver from the Simba Drivers for BigQuery page that matches your version of Excel.
- Run the ODBC driver installer.
The installer writes a user guide to the installation directory (for example,
C:/Program Files/Simba ODBC Driver for Google BigQuery
), which
contains more detailed instructions about how to configure the driver. These
instructions are also available in the
Simba ODBC installation and configuration guide.
-
Run the ODBC Data Sources Administrator program.
-
Select the User DSN tab.
-
Click the Add button.
-
Select the Simba ODBC driver for Google BigQuery from the data source dialog box and click the Finish button.
-
Set a Data source name (DSN), such as "BigQuery", "BigQuery64", or "BigQuery32".
-
Choose User authentication in the OAuth mechanism selection box.
-
Click the Sign in button.
-
Grant the ODBC driver permissions to run queries on your behalf by clicking the Allow button.
-
Copy the authorization code to your clipboard.
-
Paste the code into the Confirmation code text box.
-
Click the Refresh token text box. The ODBC driver will automatically fill in this text box by making an API request containing the confirmation code you provided.
-
Click Advanced options to configure the ODBC driver further.
-
If the BigQuery Storage API is enabled on the billing project used by the driver, check High-throughput API box for better performance when downloading query results.
-
Add a comma-separated list of projects in the Additional projects text box to view datasets in projects outside of the billing account, such as the Google Cloud public datasets hosted in the
bigquery-public-data
project. -
Click OK to finish configuring advanced options.
-
Choose the Google Cloud project ID to use as the billing project for queries by clicking the arrow on the Catalog (project) selection box.
-
Click OK to finish configuring the driver.
After the ODBC driver is configured, open Excel.
-
Go to the Data tab.
-
Select New Query > From Other Sources > From ODBC.
-
Choose Google BigQuery as the data source.
-
Don't supply a username or password. Instead, select the connection type tab for Default or Custom.
-
Select Advanced Options.
-
Enter your query in the SQL statement text box.
As an example, query the USA names public dataset for the most popular names during the baby boomer generation.
#standardSQL SELECT name, SUM(number) as total_number FROM `bigquery-public-data.usa_names.usa_1910_2013` WHERE year >= 1946 AND year <= 1964 GROUP BY name ORDER BY total_number DESC
-
Click OK. When the query completes, you will have a new sheet with about 7,400 rows.
With the driver you installed, you can connect any application which supports the ODBC API to Google BigQuery.
- Follow the BigQuery quickstart to explore the web UI and write your own queries.
- Explore more BigQuery public datasets.
- Learn how to load your own data into BigQuery.
- Reference the Simba ODBC driver installation and configuration guide.