Using a Connection String

For some applications, you might need to use a connection string to connect to your data source. For detailed information about how to use a connection string in an ODBC application, refer to the documentation for the application that you are using.

The connection strings in the following sections are examples showing the minimum set of connection attributes that you must specify to successfully connect to the data source. Depending on the configuration of the data source and the type of connection you are working with, you might need to specify additional connection attributes. For detailed information about all the attributes that you can use in the connection string, see Driver Configuration Options on page 1.

DSN Connection String Example

The following is an example of a connection string for a connection that uses a DSN:

DSN=[DataSourceName]

[DataSourceName] is the DSN that you are using for the connection.

You can set additional configuration options by appending key-value pairs to the connection string. Configuration options that are passed in using a connection string take precedence over configuration options that are set in the DSN.

DSN-less Connection String Examples

Some applications provide support for connecting to a data source using a connector without a DSN. To connect to a data source without using a DSN, use a connection string instead.

The placeholders in the examples are defined as follows, in alphabetical order:

  • [ClientID] is the Client ID to use when authenticating the connection to BigQuery.
  • [ClientSecret] is the Client Secret to use when authenticating the connection to BigQuery.
  • [PortNumber] is the number of the TCP port that the proxy server uses to listen for client connections.
  • [Project] is the BigQuery project containing the data that you want to use.
  • [Server] is the IP address or host name of the proxy server to which you are connecting.
  • [ServiceAccount] is your service account email ID.
  • [ServiceKeyPath] is the full path to a .p12 or .json key file for service account authentication.
  • [Token] is the refresh token that you obtain from Google for authorizing access to BigQuery.
  • [UserAccount] is your user account email ID.
  • [UserKeyPath] is the full path to a .json key file containing your refresh token, client ID, and client secret. For information about the required format of the .json file, see Key File Path.

Connecting to Google BigQuery using a User Account

The following is the format of a DSN-less connection string for a user account connection to Google BigQuery:

Driver=Simba Google BigQuery ODBC Connector;
OAuthMechanism=1;RefreshToken=[Token];Catalog=[Project];ClientId=[ClientID];ClientSecret=[ClientSecret];

For example:

Driver=Simba Google BigQuery ODBC Connector;
OAuthMechanism=1;RefreshToken=CH01pcNn/qFcYwUlJpkF_yyufYrqj4O4g7cdXvGgs-zT6;Catalog=testdata;ClientId=977385342095.apps.googleusercontent.com;ClientSecret=wbER7576mc_1YOII0dGk7jEE;

As an alternative to providing your refresh token directly in the string, you can save your credentials in a .json key file and then provide the full path to that file in your string. In this case, the connection string must be written in the following format:

Driver=Simba Google BigQuery ODBC Connector;
OAuthMechanism=0;Email=[UserAccount];KeyFilePath=[UserKeyPath];Catalog=[Project];

For example:

Driver=Simba Google BigQuery ODBC Connector;
OAuthMechanism=0;Email=simba@gmail.com;
KeyFilePath=C:\SecureFiles\UserKeyFile.json;Catalog=testdata;

Connecting to Google BigQuery using a Service Account

The following is the format of a DSN-less connection string for a service account connection to Google BigQuery:

Driver=Simba Google BigQuery ODBC Connector;
OAuthMechanism=0;Email=[ServiceAccount];KeyFilePath=[ServiceKeyPath];Catalog=[Project];

For example:

Driver=Simba Google BigQuery ODBC Connector;
OAuthMechanism=0;Email=application-service-account@iam.gserviceaccount.com;KeyFilePath=C:\SecureFiles\ServiceKeyFile.p12;Catalog=testdata;

Connecting to Google BigQuery through a Proxy Server

The following is the format of a DSN-less connection string for connecting to Google BigQuery with a user account through a proxy server:

Driver=Simba Google BigQuery ODBC Connector;
OAuthMechanism=1;RefreshToken=[Token];Catalog=[Project];
ProxyHost=[Server];ProxyPort=[PortNumber];

For example:

Driver=Simba Google BigQuery ODBC Connector;
OAuthMechanism=1;RefreshToken=CH01pcNn/qFcYwUlJpkF_yyufYrqj4O4g7cdXvGgs-zT6;
Catalog=testdata;ProxyHost=192.168.222.160;
ProxyPort=8000;