an ODBC driver?
We've released an ODBC driver for Google BigQuery. The driver lets you query and update BigQuery data in applications other than the Google BigQuery console. We thought we'd share some of the things you can do in these third-party applications (for example, Perl, PHP, Excel, and Oracle).
For example, if you want to work with BigQuery data in Excel, install the BigQuery ODBC driver on the machine where Excel is installed.
To do this, execute the file distribution, and follow the onscreen instructions.
The install program starts the Easysoft License Manager, because you cannot use your Easysoft product until a license is obtained.
The following types of license are available:
Complete the Name, E-Mail Address, and Company fields.
The E-Mail Address must be the same as the address used to register and download from the Easysoft web site or you will be unable to obtain trial licenses.
You're asked for a license type.
The License Manager asks what software you are licensing. Select your product from the drop-down list and then choose Next.
The License Manager requests your authorization code.
Enter the authorization code and then choose Next.
The License Manager then sends a request to the Easysoft license server to activate your license key automatically. This is the quickest method and results in your details being entered immediately into our support database.
Each of these methods involves providing Easysoft with information including your machine number (a number unique to your machine) and then waiting to receive your license key.
Instead of emailing your details to Easysoft, you can enter them directly at the Easysoft web site and your license key will be emailed to you automatically.
To use this method, choose View Request, and then visit:
In the licensing page, enter your machine number (and authorization code for a purchased license), choose Submit and your license key will be emailed to you.
When you receive the license key, you can activate it either by double-clicking the email attachment or by choosing Enter License on the License Manager main screen and pasting the license key into the dialog box.
The installation is complete.
Before the BigQuery ODBC driver can be used to connect an application to BigQuery, it's necessary to configure an ODBC data source. An ODBC data source stores the connection details for the target database (in this case, BigQuery) and the ODBC driver that is required to connect to it (in this case, the BigQuery ODBC driver).
ODBC data sources are configured in ODBC Data Source Administrator, which is included with Windows. How ODBC Data Source Administrator is run depends on whether your application is 32-bit or 64-bit:
In the Windows Run dialog box, enter:
%windir%\syswow64\odbcad32.exe
Open System and Security > Administrative Tools in Control Panel, and then open ODBC Data Sources (64-bit). (On Windows Server 2003 and earlier, the Control Panel applet that launches ODBC Data Source Administrator is labelled Data Sources.)
The following table shows the architecture of some popular applications.
Application | Architecture |
---|---|
Access | There is both a 32-bit and a 64-bit version of Access. To find out which version of Access you have, start Access, and then start Windows Task Manager. In Task Manager, choose the Processes tab. Search for MSACCESS.EXE in the list. If the process name is MSACCESS.EXE *32, Microsoft Access is 32-bit. If the process name is MSACCESS.EXE, Microsoft Access is 64-bit. |
Excel | There is both a 32-bit and a 64-bit version of Excel. To find out which version of Excel you have, start Excel, and then start Windows Task Manager. In Task Manager, choose the Processes tab. Search for Excel.exe in the list. If this process name is followed by *32, your version of Excel is 32-bit. Otherwise, your version of Excel is 64-bit. |
Oracle | The Oracle component that interacts with the MySQL ODBC driver is called DG4ODBC. There is both a 32-bit and a 64-bit version of DG4ODBC. To find out which version of DG4ODBC you have, start the Windows Task Manager and choose the Processes tab. In a Command Prompt window, type dg4odbc --help . In the Windows Task Manager, search for the DG4ODBC process. If the Image Name is dg4odbc.exe *32 DG4ODBC is 32-bit. If the Image Name is dg4odbc.exe DG4ODBC is 64-bit. Press CTRL+C in the Command Prompt window, when you have used the Windows Task Manager to find out DG4ODBC's architecture. |
SQL Server |
There is both a 32-bit and a 64-bit version of SQL Server. To find out which version of SQL Server you have, connect to your SQL Server instance, and then run this SQL statement:
|
GoodData | CloudConnect Designer is a 64-bit application. |
MicroStrategy | MicroStrategy is a 32-bit application. |
Oracle Business Intelligence Enterprise Edition (OBIEE) | The OBIEE component that interacts with the ODBC driver is called the Oracle BI Administration Tool. The Oracle BI Administration Tool is 64-bit. |
PHPRunner | PHPRunner is a 32-bit application. |
QlikView | QlikView is a 32-bit application if the Force 32 Bit check box is selected. Otherwise, QlikView is a 64-bit application. |
SAP BusinessObjects | Central Management Server is a 64-bit application. Business View Manager, Information Design Tool and Web Intelligence Rich Client are 32-bit applications. |
SAP Crystal Reports | Crystal Reports is a 32-bit application. |
Tableau | Tableau is a 32-bit application. |
TIBCO Spotfire | TIBCO Spotfire is a 64-bit application. |
In ODBC Data Source Administrator:
Setting | Value |
---|---|
DSN | BigQuery |
Refresh Token | Choose the Authenticate and obtain token and grant the BigQuery ODBC driver permission to access your BigQuery data to populate this field. |
select * from MyTable limit 10
Strawberry Perl is a Perl distribution for Windows that includes the necessary middleware layers (Perl DBI and Perl DBD::ODBC) to enable the BigQuery ODBC driver to connect your Perl applications to BigQuery.
#!/usr/bin/perl -w use strict; use DBI; my $dbh = DBI-> connect('dbi:ODBC:MyBigQueryDataSource'); my $sql = "SELECT residential_ratio FROM `bigquery-public-data.hud_zipcode_crosswalk.census_tracts_to_zipcode` LIMIT 10"; # Prepare the statement. my $sth = $dbh->prepare($sql) or die "Can't prepare statement: $DBI::errstr"; # Execute the statement. $sth->execute(); my($BigQueryCol); # Fetch and display the result set value. while(($BigQueryCol) = $sth->fetchrow()){ print("$BigQueryCol\n"); } $dbh->disconnect if ($dbh);
#!/usr/bin/perl -w use strict; use warnings; use DBI; my $data_source = q/dbi:ODBC:MyBigQueryDataSource/; my $h = DBI-"connect($data_source) or die "Can't connect to $data_source: $DBI::errstr"; $h->{RaiseError} = 1; my $s = $h->prepare(q/insert into MyTable(MyStringCol, MyIntegerCol, MyFloatCol, MyNumericCol, MyBooleanCol,MyDateCol,MyTimeCol,MyDateTimeCol,MyTimeStampCol) values(?,?,?,?,?,?,?,?,?)/); my $string='MyValue'; my $int=46683; my $float=8.3; my $numeric=0.00333; my $bool=0; my $date='2021-01-23'; my $time='00:00:20'; my $datetime='2021-02-05 00:00:00'; my $timestamp='2019-01-27 00:00:00'; $s->bind_param(1, $string, DBI::SQL_WVARCHAR); $s->bind_param(2, $int, DBI::SQL_INTEGER); $s->bind_param(3, $float, DBI::SQL_FLOAT); $s->bind_param(4, $numeric, DBI::SQL_NUMERIC); #$s->bind_param(5, $bignumeric, DBI::SQL_WVARCHAR); $s->bind_param(5, $bool, DBI::SQL_TINYINT); $s->bind_param(6, $date, DBI::SQL_DATE); $s->bind_param(7, $time, DBI::SQL_TIME); $s->bind_param(8, $datetime, DBI::SQL_DATETIME); $s->bind_param(9, $timestamp, DBI::SQL_TIMESTAMP); $s->execute($string,$int,$float,$numeric,$bool,$date,$time,$datetime,$timestamp); $h->disconnect;
#!/usr/bin/perl -w use strict; use warnings; use DBI; my $data_source = q/dbi:ODBC:MyBigQueryDataSource/; my $h = DBI->connect($data_source) or die "Can't connect to $data_source: $DBI::errstr"; $h->{RaiseError} = 1; my $s = $h->prepare(q/UPDATE MyTestTable SET MyStringCol = ? WHERE MyStringCol = 'MyValue' /); my $string='MyNewValue'; $s->bind_param(1, $string, DBI::SQL_WVARCHAR); $s->execute($string); $h->disconnect;
<?php $con = odbc_connect("MyBigQueryDataSource", "", ""); $err = odbc_errormsg(); if (strlen($err) <> 0) { echo odbc_errormsg(); } else { $rs2 = odbc_exec($con, "select MyCol from MyTable"); odbc_result_all($rs2); odbc_close($con); } ?>
Follow these steps to return data from BigQuery to Microsoft Excel by using Microsoft Query:
Note that for large result sets, you may have to have to filter the data using Excel before the data can be returned to the worksheet.
%ORACLE_HOME%\hs\admin
directory. Create a copy of the file initdg4odbc.ora
. Name the new file initbq.ora
.
Note In these instructions, replace %ORACLE_HOME%
with the location of your Oracle HOME
directory. For example, C:\oraclexe\app\oracle\product11円.2.0\server
.
HS_FDS_CONNECT_INFO = MyBigQueryDataSource
#HS_FDS_TRACE_LEVEL = <trace_level>
%ORACLE_HOME%\network\admin\listener.ora
that creates a SID_NAME
for DG4ODBC. For example:
SID_LIST_LISTENER = (SID_LIST = (SID_DESC= (SID_NAME=bq) (ORACLE_HOME=%ORACLE_HOME%) (PROGRAM=dg4odbc) ) )
%ORACLE_HOME%\network\admin\tnsnames.ora
that specifies the SID_NAME
created in the previous step. For example:
BQ = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle_host)(PORT = 1521)) (CONNECT_DATA = (SID = bq) ) (HS = OK) )
Replace oracle_host
with the host name of your Oracle machine.
cd %ORACLE_HOME%\bin lsnrctl stop lsnrctl start
CREATE PUBLIC DATABASE LINK bqlink CONNECT TO "mydummyuser" IDENTIFIED BY "mydummypassword" USING 'bq';
SELECT * FROM "MyTable"@BQLINK;
%ORACLE_HOME%\hs\trace
directory. To enable DG4ODBC tracing, add the line HS_FDS_TRACE_LEVEL = DEBUG
to initbq.ora
and then start or restart the Oracle listener. If the trace
directory does not exist, create it.C:\SQL.log
), change the trace file location to the Windows TEMP
directory. For example, C:\Windows\Temp\SQL.log
.