Databricks Google Sheets Connector
raw JSON → 0.8.0 verified Mon Apr 27 auth: no python
A Python library for reading and writing Google Sheets data from Databricks notebooks. Version 0.8.0 supports Python >=3.6. It wraps the Google Sheets API and provides a simple DataFrame-centric interface. Releases are infrequent; no breaking changes recently announced.
pip install databricks-google-sheets Common errors
error ModuleNotFoundError: No module named 'databricks_google_sheets' ↓
cause Package not installed or installed under incorrect name (e.g., 'databricks-google-sheets' in pip list).
fix
Install via pip: pip install databricks-google-sheets. Import with underscores.
error GoogleSheetsClient.get_credentials() missing required positional argument: 'service_account_key' ↓
cause Did not provide the service account key JSON file path.
fix
Pass a valid path to a service account key JSON file: GoogleSheetsClient.get_credentials(service_account_key='/path/to/key.json')
error AttributeError: 'ServiceAccountCredentials' object has no attribute 'to_json' ↓
cause Incompatible version of google-auth or gspread. The library expects an older interface.
fix
Pin google-auth to <=1.35.0 and gspread to <=3.7.0: pip install google-auth==1.35.0 gspread==3.7.0
Warnings
gotcha The library expects a service account key file path, not JSON string. Use absolute path or Databricks secret scope. ↓
fix Store the key file in DBFS or use Databricks secrets with dbutils.secrets.get() and write to a temp file.
gotcha Google Sheets API quotas are low for free tier. Frequent writes may exceed limits. ↓
fix Implement rate limiting or batch updates using gspread directly if needed.
deprecated The method `write_to_sheet` expects a DataFrame; passing a list may cause silent errors. ↓
fix Always convert data to pandas DataFrame before calling write_to_sheet.
Imports
- GoogleSheetsClient wrong
from databricks.google_sheets import GoogleSheetsClientcorrectfrom databricks_google_sheets import GoogleSheetsClient
Quickstart
from databricks_google_sheets import GoogleSheetsClient
import os
# Set credentials via environment variables or Databricks secrets
scope = ['https://www.googleapis.com/auth/spreadsheets']
creds = GoogleSheetsClient.get_credentials(
service_account_key=os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', '')
)
client = GoogleSheetsClient(creds)
# Read a sheet
url = 'https://docs.google.com/spreadsheets/d/your-sheet-id/edit'
df = client.read_from_url(url, sheet_name='Sheet1')
print(df.head())