Skip to main content

Neither this package nor the author, tomathon, are affiliated with or endorsed by Google. The inclusion of Google trademark(s), if any, upon this webpage is solely to identify Google contributors, goods, or services, and not for commercial purposes.


🚀 FastGCP is the faster, more intuitive way of working with Google Cloud Platform services and frameworks.

The fastgcp package is built on top of canonical Google Python packages(s) without any alteration to Google's base code.

Full documentation can be found here (WIP)


Installation

fastgcp is installed using pip with the command:

$ pip install fastgcp


The BigQuery class

One of the main FastGCP classes is BigQuery. It allows users to work with BQ database tables and objects in a more Pythonic way.

Quickstart

Import BigQuery:

from fastgcp import BigQuery

Initialize BigQuery using your GCP Project name:

bq = BigQuery(project_id = "gcp-project-name")

Alternatively, to initialize using a specific service account key, pass the full key path to your key.json:

bq = BigQuery(
    project_id = "gcp-project-name",
    service_acct_key_path = "/full/path/to/your/service/account/key.json"
)

Common BigQuery Methods:

bq.read_bigquery

Read an existing BigQuery table into a DataFrame

read_bigquery(bq_dataset_dot_table = None, date_cols = [], preview_top = None, to_verbose = True)

  • bq_dataset_dot_table : the "dataset-name.table-name" path of the existing BigQuery table
  • date_cols : [optional] column(s) passed inside a list that should be parsed as dates
  • preview_top : [optional] only read in the top N rows
  • to_verbose : should info be printed? defaults to True
  • use_polars : should a polars DataFrame be returned instead of a pandas DataFrame? Defaults to True

EX:

my_table = bq.read_bigquery("my_bq_dataset.my_bq_table")

my_table = bq.read_bigquery("my_bq_dataset.my_bq_table", date_cols = ['date'])

-----------

bq.read_custom_query

Read an existing BigQuery table into a DataFrame, using a custom SQL expression

read_custom_query(custom_query, to_verbose = True)

  • custom_query : the custom BigQuery SQL query that will produce a table to be read into a DataFrame
  • to_verbose : should info be printed? defaults to True
  • use_polars : should a polars DataFrame be returned instead of a pandas DataFrame? Defaults to True

EX:

my_custom_table = bq.read_custom_query("""
    SELECT
        date,
        sales,
        products
    FROM
        my_bq_project_id.my_bq_dataset.my_bq_table
    WHERE
        sales_month = 'June'
""")

-----------

bq.write_bigquery

Write a DataFrame to BigQuery

write_bigquery(df, bq_dataset_dot_table = None, use_schema = None, append_to_existing = False, to_verbose = True)

  • df : the DataFrame to be written to a BigQuery table
  • bq_dataset_dot_table : the "dataset-name.table-name" path of the existing BigQuery table
  • use_schema : [optional] a custom schema for the BigQuery table. NOTE: see bq.guess_schema below
  • append_to_existing : should the DataFrame be appended to an existing BigQuery table? defaults to False (create new / overwrite)
  • to_verbose : should info be printed? defaults to True

EX:

bq.write_bigquery(my_df, "my_bq_dataset.my_data")

bq.write_bigquery(my_df, "my_bq_dataset.my_data", append_to_existing = True)

-----------

bq.send_query

Send a custom SQL query to BigQuery. Process is carried out within BigQuery. Nothing is returned

send_query(que, to_verbose = True)

  • que : the custom SQL query to be sent and carried out within BigQuery
  • to_verbose : should info be printed? defaults to True

EX:

bq.send_query("""
    CREATE TABLE my_bq_project_id.my_bq_dataset.my_new_bq_table AS 
    (
        SELECT
            date,
            sales,
            products
        FROM
            my_bq_project_id.my_bq_dataset.my_bq_table
        WHERE
            sales_month = 'June'
    )
""")

-----------

Metadata

Release files for fastgcp 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastgcp 0.1.1
File Size Uploaded Provenance Actions
fastgcp-0.1.1.tar.gz 7.4 kB Without provenance Details for fastgcp-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastgcp 0.1.1
File Interpreter ABI Platform Actions
fastgcp-0.1.1-py3-none-any.whl Python 3 none any Details for fastgcp-0.1.1-py3-none-any.whl

Total release size: 14.2 kB

Release files / fastgcp-0.1.1.tar.gz

Download URL fastgcp-0.1.1.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
064c3c2e5dab03b4730b53b32b084bac79c087cdec94e28934f9f66c10724200
BLAKE2b-256 checksum
How to use checksums
c204246abf9d33e4c1dc32007f5a9c6f0c2723467a7099f7d48774c586bf6e11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / fastgcp-0.1.1-py3-none-any.whl

Download URL fastgcp-0.1.1-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23d0d2abe0c1d6fa76d3f1cef140c54374b9a76dad36e3e9190e6469af012830
BLAKE2b-256 checksum
How to use checksums
9679b17d4101860ab08f335bd66efa93fffb2dd9a4b677edec3481fe232da163
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Security for fastgcp 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page