Skip to main content

Unofficial IPython magic command for bigquery

Project description

another-bigquery-magic

Unofficial bigquery magic Command for IPython notebook

Installation

# from pypi
$ pip install another-bigquery-magic

# alternatively, from github
$ git clone https://github.com/kota7/another-bigquery-magic.git --depth 1
$ pip install -U ./another-bigquery-magic

Usage

# Set the project ID
project_id = "<google-cloud-project-id>"
!gcloud config set project {project_id}
# If you are authenticated to the google cloud already, skip this cell.
# Otherwise, authenticate with your choice of method.

# Example 1. Authentication on colab
from google.colab import auth
auth.authenticate_user()

# Example 2. Authentication by user log-in
# Note: to access external table with google drive,
#       we also need "https://www.googleapis.com/auth/drive" in the scope
!gcloud auth application-default login --scopes="https://www.googleapis.com/auth/bigquery"

# Example 3. Authentication with a local json file
jsonfile = "<json-file-path>"
%config BigqueryMagic.localjson = jsonfile
# Load the bq magic command
%load_ext bq

# %bq magic command runs the query and returns the pandas data frame
%bq SELECT 1 AS test
Start query at 2024-01-12 15:31:07.286991
End query at 2024-01-12 15:31:10.047083 (Execution time: 0:00:02.760092, Processed: 0.0 GB)
test
0 1

See example.ipynb for more examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

another-bigquery-magic-0.1.3.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

another_bigquery_magic-0.1.3-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page