Skip to main content

Python package that loads data from the web and deploys a corresponding external table definition, so that the data can be queried using standard SQL.

Project description

vestapol

vestapol is a Python package that loads data from the web and deploys a corresponding external table definition, so that the data can be queried using standard SQL.

"Vestapol" is an open D Major tuning for the guitar. It is named after a 19th-century composition distributed in some of the earliest instructional guides for guitar.

Usage

from vestapol.web_resources.csv_resource import CSVResource
from vestapol.destinations.gcp_destination import GoogleCloudPlatform


nyt_covid_data_2022 = CSVResource(
    name="nyt_covid19_us_counties_2022",
    base_url="https://raw.githubusercontent.com/",
    endpoint="nytimes/covid-19-data/master/rolling-averages/us-counties-2022.csv",
    version="v0",
    skip_leading_rows=1,
)

destination = GoogleCloudPlatform()

nyt_covid_data_2022.load(destination)
tablename = destination.create_table(nyt_covid_data_2022)


from google.cloud import bigquery

client = bigquery.Client()
query = f"""
    select date, state, county, cases_avg_per_100k
    from `{tablename}`
    where requested_at = '{nyt_covid_data_2022.requested_at}'
    limit 5
"""
query_job = client.query(query)
for row in query_job.result():
    print(row)

Prerequisites

Installation of this project requires Poetry 1.2+ and Python version 3.9+.

Older version of poetry can be updated by running:

poetry self update
poetry --version

Installation

Install vestapol and its dependencies by running:

poetry install

Testing

Run tests with the following command:

poetry run pytest

Environment Variables

  • GCS_BUCKET_NAME: the Google Cloud Storage bucket where data is loaded (e.g. inq-warehouse-waligob)
  • GCS_ROOT_PREFIX: the GCS prefix where data is loaded (e.g. data_catalog)
  • GBQ_PROJECT_ID: the BigQuery project identifier (e.g. inq-warehouse)
  • GBQ_DATASET_ID: the BigQuery dataset where external tables will be created (e.g. data_catalog_waligob)
  • GBQ_DATASET_LOCATION: the BigQuery dataset location (e.g. US)
  • GOOGLE_APPLICATION_CREDENTIALS=: location of the GCS service account keyfile (e.g. ~/inq-warehouse-f0962a57089e-inf.json)

Publishing to PyPI

Instructions for pushing new versions of vestapol to PyPI:

  1. Update CHANGELOG.md. Include Additions, Fixes, and Changes.

  2. Update project version using either a valid PEP 440 string or a valid bump rule following Semantic Versioning.

    poetry version <version string or bump rule>
  1. Create a release and check the CD Pipeline action to ensure that the project was built and published to PyPI successfully.

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

vestapol-0.0.28.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vestapol-0.0.28-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file vestapol-0.0.28.tar.gz.

File metadata

  • Download URL: vestapol-0.0.28.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.9.21 Linux/6.11.0-1018-azure

File hashes

Hashes for vestapol-0.0.28.tar.gz
Algorithm Hash digest
SHA256 6cedbd0394450f9c79299ba0da6d4e89899ed5098abea555274fc57779587366
MD5 18e986e9065acfa0d61e2da7c60e5153
BLAKE2b-256 7955cde8485031fdeeff1363dca9d4e9f6985d9c73044932770f1344ddf96f2b

See more details on using hashes here.

File details

Details for the file vestapol-0.0.28-py3-none-any.whl.

File metadata

  • Download URL: vestapol-0.0.28-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.9.21 Linux/6.11.0-1018-azure

File hashes

Hashes for vestapol-0.0.28-py3-none-any.whl
Algorithm Hash digest
SHA256 a1e9c3f20fe6549dba9c83a41f425146b78261c75c0ca77a62b034d3ffa87590
MD5 46d1de32077c40ac85a852f5f5fac718
BLAKE2b-256 79ead250db361af99c40a25c80a5957ab06903cf471cd68554efa726452e615b

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