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
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
Release history Release notifications | RSS feed
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.3.tar.gz
(24.8 kB
view details)
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 rdxz2_utill-0.1.3.tar.gz.
File metadata
- Download URL: rdxz2_utill-0.1.3.tar.gz
- Upload date:
- Size: 24.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15fcb0a0072b9fd6faba39f9e82bdf581f9159243d051d89b8a79c3239d22e41
|
|
| MD5 |
95f47a0d660dcd45a9af0dfeb65db03d
|
|
| BLAKE2b-256 |
6099b085bdf3e8d432408ad7b33da43054db23bc60bb1dc3c7bbc1e6de1712d8
|
File details
Details for the file rdxz2_utill-0.1.3-py3-none-any.whl.
File metadata
- Download URL: rdxz2_utill-0.1.3-py3-none-any.whl
- Upload date:
- Size: 32.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10c2ffa1b0dfc8632742d5a24d0349ae6aa520766bb9002d403126687188ac8e
|
|
| MD5 |
0d08183b8f026ee586a605f18ba1181a
|
|
| BLAKE2b-256 |
35e48ab12197676d190250e0d7bf92d6efa46b64fa5160b2398d61863db080f1
|