Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing google auth Credentials directly to BQ connector #1042

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions parsons/google/google_bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from google.cloud import bigquery, exceptions
from google.cloud.bigquery import dbapi
from google.cloud.bigquery.job import LoadJobConfig
from google.oauth2.credentials import Credentials

from parsons.databases.database_connector import DatabaseConnector
from parsons.databases.table import BaseTable
Expand Down Expand Up @@ -143,7 +144,7 @@ class GoogleBigQuery(DatabaseConnector):

def __init__(
self,
app_creds=None,
app_creds: Optional[Union[str, dict, Credentials]] = None,
project=None,
location=None,
client_options: dict = {
Expand All @@ -156,7 +157,11 @@ def __init__(
):
self.app_creds = app_creds

setup_google_application_credentials(app_creds)
if isinstance(app_creds, Credentials):
self.credentials = app_creds
else:
self.credentials = None
setup_google_application_credentials(app_creds)

self.project = project
self.location = location
Expand Down Expand Up @@ -185,6 +190,7 @@ def client(self):
project=self.project,
location=self.location,
client_options=self.client_options,
credentials=self.credentials,
)

return self._client
Expand Down