Skip to main content

Your daily Python utility

Project description

Using this library

Installation

pip install utill

Usage syntax

from utill.__MODULE__ import __OBJECT__

Example

# Using the string module
from utill.my_string import generate_random_string

print(generate_random_string(16))

Initial set up

This package contains CLI command

utill conf init

Additional extensions

Syntax

pip install utill[__EXTENSION_NAME__]

Extension list:

  • google-cloud
  • postgresql
  • pdf

Per module usages

my_bq

Executing a query

from utill.my_bq import BQ

# Initialize BigQuery client
bq = BQ()

# Execute a query, returns iterable QueryJob
job = bq.execute_query('...')

# Convert into list for quick data conversion
results = list(job)

# Iterate the results
for row in job:
    # Do anything with the row

Uploading CSV file into BigQuery table

from utill.my_bq import BQ, Dtype, LoadStrategy

# Initialize BigQuery client
bq = BQ()

# Load the data
filename = '/path/to/file.csv'  # Your local CSV file location
bq_table_fqn = 'project.dataset.table'  # An FQN (fully qualified name) of a BigQuery table to export
columns = {
    'col1': Dtype.INT64,
    'col2': Dtype.STRING,
    'col3': Dtype.DATE,
    ...
}
partition_col = 'col3'  # Optional, for performance and cost optimization
cluster_cols = ['col1']  # Optional, for performance and cost optimization
load_strategy = LoadStrategy.APPEND  # Optional, default to APPEND
bq.upload_csv(filename, bq_table_fqn, columns, partition_col, cluster_cols, load_strategy)

Exporting query into CSV

from utill.my_bq import BQ

# Initialize BigQuery client
bq = BQ()

query = 'SELECT * FROM `project.dataset.table`'  # The query to export
filename = '/path/to/file.csv'  # Destination CSV file location
bq.download_csv(query, filename)

Exporting table into XLSX

from utill.my_bq import BQ

# Initialize BigQuery client
bq = BQ()

bq_table_fqn = 'project.dataset.table'  # An FQN (fully qualified name) of a BigQuery table to export
filename = '/path/to/file.xlsx'  # Destination XLSX file location
bq.download_xlsx(src_table_fqn, dst_filename)

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

rdxz2_utill-0.1.4.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

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

rdxz2_utill-0.1.4-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

Details for the file rdxz2_utill-0.1.4.tar.gz.

File metadata

  • Download URL: rdxz2_utill-0.1.4.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rdxz2_utill-0.1.4.tar.gz
Algorithm Hash digest
SHA256 1721d7d6ee46433a36db5b7dbdf64f3356576f92c6b3a3c371dc3d0c0d836790
MD5 bd9e2fcad3029a74db1f1107b6627935
BLAKE2b-256 55bea42da3f71998b16fa862d0febcccb8d4fc36febd1d4ec13538cb9ce91b93

See more details on using hashes here.

File details

Details for the file rdxz2_utill-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: rdxz2_utill-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 36.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rdxz2_utill-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 57230af26c4e896995f287f39e2cc7ad9dd9646d7005f60cf0a56a93ebfa1f16
MD5 e01c98fd79acee686704af877e745caa
BLAKE2b-256 16ed8e9146c6600859aaf4ac7170fc960a417d986b0bf8655a25e870e1931751

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