Provides some helper functions previously used by The Sensible Code Company's Data Services team.
Project description
data-services-helpers
A module containing classes and functions previously used by The Sensible Code Company's Data Services team.
(The Sensible Code Company is now Cantabular Ltd.)
Warning: This is now in maintenance mode.
It has been updated to work with Python 3.14 but there are no guarantees on future maintenance.
Installation
For the current release:
pip install dshelpers
Usage
batch_processor
with batch_processor(callback_function(), batch_size=2000) as b:
# loop to make rows here
b.push(row)
Here, push on the batch_processor queues items in a list. When the
context manager is exited, calls the callback_function with the list of
items.
Often used to bundle multiple calls to scraperwiki.sqlite.save when saving
data to a database.
install_cache
install_cache(expire_after=12 * 3600, cache_post=False)
For installing a requests_cache; requires the
requests-cache package.
expire_after is the cache expiry time in seconds.
cache_post defines if HTTP POST requests should be cached as well.
download_url
download_url(url, back_off=True, **kwargs)
Retrieve the content of url, by default using requests.request('GET', url),
and return a file-like object. If back_off=True, then this will retry (with
backoff) on failure; otherwise, only one attempt is made. Returns the
response.content as a StringIO object.
The **kwargs can be arguments that
requests recognises, e.g.
method or headers.
request_url
request_url(url, back_off=True, **kwargs)
As download_url, but returns the response object.
Tests
Run with make test.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dshelpers-2.0.1.tar.gz.
File metadata
- Download URL: dshelpers-2.0.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
469bfecde03224bc4e154fe03bb789c1039639c419d09090d07b7b1061ecaeb2
|
|
| MD5 |
3a57db17332d814ef3a07c722f5edfd0
|
|
| BLAKE2b-256 |
fd9d438692c59c0a3c061c1e2c0299c76f0808e173882fb3b3be13202764ee96
|
Provenance
The following attestation bundles were made for dshelpers-2.0.1.tar.gz:
Publisher:
ci-build.yml on cantabular/data-services-helpers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dshelpers-2.0.1.tar.gz -
Subject digest:
469bfecde03224bc4e154fe03bb789c1039639c419d09090d07b7b1061ecaeb2 - Sigstore transparency entry: 1066057322
- Sigstore integration time:
-
Permalink:
cantabular/data-services-helpers@3ece13a1bfe911b8c4816b8eddf94457a9bf71a2 -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/cantabular
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-build.yml@3ece13a1bfe911b8c4816b8eddf94457a9bf71a2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dshelpers-2.0.1-py3-none-any.whl.
File metadata
- Download URL: dshelpers-2.0.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29706ffb699ae4aa930973f45dbc7827058a07c534b6a6143bd23fa51eab8b22
|
|
| MD5 |
7a713d65e420c271cdba7983886d9828
|
|
| BLAKE2b-256 |
04287a6e293416b291bcd3e8c8bddd96bccbe51f846f5b53ce3cd6ee206be6b2
|
Provenance
The following attestation bundles were made for dshelpers-2.0.1-py3-none-any.whl:
Publisher:
ci-build.yml on cantabular/data-services-helpers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dshelpers-2.0.1-py3-none-any.whl -
Subject digest:
29706ffb699ae4aa930973f45dbc7827058a07c534b6a6143bd23fa51eab8b22 - Sigstore transparency entry: 1066057337
- Sigstore integration time:
-
Permalink:
cantabular/data-services-helpers@3ece13a1bfe911b8c4816b8eddf94457a9bf71a2 -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/cantabular
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-build.yml@3ece13a1bfe911b8c4816b8eddf94457a9bf71a2 -
Trigger Event:
push
-
Statement type: