Skip to main content

Python utility for creating and querying temporary tables in Google Cloud Environments.

Project description

gc_temp_tables lets you easily create and query temporary tables within Google Cloud environments. The user has the option to work within a session and/or use external tables. The functions in gc_temp_tables are below:

  • create_bq_session().
  • get_external_table_config(filename_in_bucket).
  • create_temp_table(query)
  • query_temp_table()
  • delete_temp_table().

More information, include code snippet at: https://github.com/AymoneKouame/data-science-utilities/blob/main/README.md#1---package-gc_temp_tables

gc_temp_tables was originally written to be used within the All of Us Researcher Workbench environment but can be used in other Google Cloud Environments.

# 1.install the package if not already done
pip install gc_temp_tables 

# 2. import the module
from gc_temp_tables import gc_temp_tables as gct

# 3. create/initialize a session 
session_id = gct.create_bq_session()

# 5. create a temporay table from an external file

## 5.a Grab external table configuration
ext_config = gct.get_external_table_config(filename_in_bucket='example.parquet')

## 5.b Create table
gct.create_temp_table(f'''CREATE TEMP TABLE example_table AS (SELECT * FROM example)'''
		   , ext_table_def_dic = {example: ext_config}, session_id = session_id)

# 6. query the table and join with another table in Google Big Query
df = gct.query_temp_table(f'''
	SELECT t.*,  age
	FROM example_table
	JOIN person USING(person_id)''', session_id = session_id)

# 7. Delete unused temp tables
df = gct.delete_temp_table('example_table', session_id = session_id)

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

gc_temp_tables-1.0.0.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file gc_temp_tables-1.0.0.tar.gz.

File metadata

  • Download URL: gc_temp_tables-1.0.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.12

File hashes

Hashes for gc_temp_tables-1.0.0.tar.gz
Algorithm Hash digest
SHA256 da76475135cd5cfde48ad448a62921c0fe2edbf9112cde937b07b2865f875335
MD5 b45ad72e2fc460e46db7ff3a91543ffb
BLAKE2b-256 fdc76df889f5a4a0a7cfd0992d780aed00460059d65e37e6ca7f410def4aa711

See more details on using hashes here.

Supported by

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