Connect to BigQuery from Microsoft Excel using ODBC
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
Before you begin
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.
Downloading the driver
- Check whether your version of Excel is 32-bit or 64-bit.
- Download the latest version of thevODBC 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.
Configuring the driver
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".
Authenticating the driver
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.
Configuring advanced options
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
Click OK to finish configuring advanced options.
Finish configuring the driver
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.
Running a query
After the ODBC driver is configured, open Excel.
Opening the query dialog
- 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.
Entering a query
- Select Advanced Options.
Enter your query in the SQL statement text box.
#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.