Skip to main content

Klondike is a suite of database connectors, powered by Polars

Project description

Klondike

Klondike Logo

Klondike offers a lightweight, unified API to read and write data to and from various database and data warehouse types using Polars DataFrames.

Installation

Installing Klondike

Install at the command line

pip install klondike

Installing Rust

Since Polars leverages Rust speedups, you need to have Rust installed in your environment as well. See the Rust installation guide here.

Usage

In this demo we'll connect to Google BigQuery, read data, transform it, and write it back to the data warehouse.

First, connect to the BigQuery warehouse by supplying the BigQueryConnector() object with the relative path to your service account credentials.

from klondike import BigQueryConnector

# Connect Klondike to Google BigQuery
bq = BigQueryConnector(
    app_creds="dev/nba-player-service.json"
)

Next, supply the object with a SQL query in the read_dataframe() function to redner a DataFrame object:

# Write some valid SQL
sql = """
SELECT
    *
FROM nba_dbt.cln_player__averages
ORDER BY avg_points DESC
"""


# Pull BigQuery data into a Polars DataFrame
nyk = bq.read_dataframe(sql=sql)

Now that your data is pulled into a local instance, you can clean and transform it using standard Polars functionality - see the docs for more information.

# Perform some transformations
key_metrics = [
    "avg_offensive_rating",
    "avg_defensive_rating",
    "avg_effective_field_goal_percentage"
]

summary_stats = nyk[key_metrics].describe()

Finally, push your transformed data back to the BigQuery warehouse using the write_dataframe() function:

# Write back to BigQuery
bq.write_dataframe(
    df=summary_stats,
    table_name="nba_dbt.summary_statistics",
    if_exists="truncate"
)

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

klondike-0.3.0.tar.gz (3.0 MB view details)

Uploaded Source

Built Distribution

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

klondike-0.3.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file klondike-0.3.0.tar.gz.

File metadata

  • Download URL: klondike-0.3.0.tar.gz
  • Upload date:
  • Size: 3.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for klondike-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b1270da3eca6851cfe663dd773c8b1e62111982cfa25dd8b4f609a982f8118e6
MD5 b1d9df9af53e77f2000dae8b743dceda
BLAKE2b-256 72b6a7f32ce45813c161f9f8477b85518b51299a710e18c5d63760fee4997219

See more details on using hashes here.

Provenance

The following attestation bundles were made for klondike-0.3.0.tar.gz:

Publisher: publish.yml on IanRFerguson/klondike

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file klondike-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: klondike-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for klondike-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a3ff448cfaa702f9ff794071b6af29031aa26acc3dda17bec45cce6527b3d697
MD5 7d1b2b134dc0fa38d55c872fc0e24d87
BLAKE2b-256 ec6c451d29adaa4bd103a46aaa09c3b4e54e8f051b5423d4f389858ab629fc92

See more details on using hashes here.

Provenance

The following attestation bundles were made for klondike-0.3.0-py3-none-any.whl:

Publisher: publish.yml on IanRFerguson/klondike

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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