semvec/pypi-packages huggingface dataset:
bq-utils 0.1.1
A collection of BigQuery utilities
License: MIT

# bq-utils - A collection of BigQuery utilities
Currently the utilities covered in this library are limited to managing table and view descriptions.
It's quite useful to have the field descriptions available on 
the schema tab and on the query editor pane on the BigQuery UI and this library helps you with uploading them and copying them around.
## Install
```bash
pip install bq-utils
```
## Python
### Copy descriptions between tables and views
```python
from google.cloud import bigquery
from bqutils.bigquery_description_manager import BigQueryDescriptionManager

bq_client = bigquery.Client()
description_manager = BigQueryDescriptionManager(bq_client)
source_table_id = 's_project.s_dataset.s_table'
target_table_id = 't_project.t_dataset.t_table'
description_manager.copy_field_descriptions(source_table_id, target_table_id)
```

### Upload descriptions from csv
```python
from google.cloud import bigquery
from bqutils.bigquery_description_manager import BigQueryDescriptionManager

bq_client = bigquery.Client()
description_manager = BigQueryDescriptionManager(bq_client)
descriptions_csv_path = 'table_descriptions.csv'
target_table_id = 't_project.t_dataset.t_table'
description_manager.upload_field_descriptions(descriptions_csv_path, target_table_id)
```

## Command line
### Usage
```bash
usage: __main__.py [-h] [--source SOURCE] --target TARGET
                   [--csv_path CSV_PATH] [--debug]
                   {desccopy,descupload}

Copy or upload field descriptions for BigQuery tables/views

positional arguments:
  {desccopy,descupload}

optional arguments:
  -h, --help            show this help message and exit
  --source SOURCE       fully-qualified source table ID
  --target TARGET       fully-qualified target table ID
  --csv_path CSV_PATH   path for the csv file
  --debug               set debug mode on, default is false
```
### Copy descriptions between tables and views
```bash
python -m bqutils desccopy --source s_project.s_dataset.s_table --target t_project.t_dataset.t_table
```

### Upload descriptions from csv
```bash
python -m bqutils descupload --csv_path table_descriptions.csv --target t_project.t_dataset.t_table
```
pysh-lib 0.0.2
Pythonically simple alternative to shell scripts and subprocess
License: MIT
Requires Python: >=3.6
Keywords: scripting shell subprocess cli

Pysh is a library for running external commands from a Python program,
with the usual concision and clarity that Python achieves in other domains.

## Usage

Simple commands are simple:

    from pysh import check_cmd, try_cmd

    check_cmd('gpg --decrypt --output {} {}', cleartext_path, cryptotext_path)

    if not try_cmd('git diff-index --quiet HEAD'):
        raise RuntimeError("worktree not clean")

    repo_root = slurp_cmd('git rev-parse --show-toplevel')
    # "slurp" strips trailing newlines, just like shell `$(...)`

### Writing command lines

Command lines offer a `format`-like minilanguage, powered by
`pysh.shwords`.  The format string is automatically split to form the
command's list of arguments, providing shell-script-like
convenience...  but the interpolated data never affects the split,
avoiding classic shell-script bugs.

    from pysh import shwords, check_cmd

    shwords('rm -rf {tmpdir}/{userdoc}', tmpdir='/tmp', userdoc='1 .. 2')
    # -> ['rm', '-rf', '/tmp/1 .. 2']

    check_cmd('rm -rf {tmpdir}/{userdoc}', tmpdir='/tmp', userdoc='1 .. 2')
    # removes `/tmp/1 .. 2` -- not `/tmp/1`, `..`, and `2`

A format-minilanguage extension `{...!@}` substitutes in a whole list:

    check_cmd('grep -C2 TODO -- {!@}', files)

Each function taking a command line also has a twin, named with `_f`,
that opts into f-string-like behavior:

    from pysh import check_cmd, check_cmd_f

    check_cmd_f('{compiler} {cflags!@} -c {source_file} -o {object_file}')

    # equivalent to:
    check_cmd('{} {!@} -c {} -o {}',
              compiler, cflags, source_file, object_file)

### Pipelines

Pipelines are composed with the `|` operator.  Each stage (or
"filter") in the pipeline can be an external command, or Python code.

Most often pipelines are built from the filters offered in the
`pysh.cmd` module.  You can consume the output with `pysh.slurp`:

    import pysh
    from pysh import cmd

    hello = pysh.slurp(cmd.echo(b'hello world')
                       | cmd.run('tr h H'))
    # -> b'Hello world'

Or iterate through it:

    for commit_id in (cmd.run('git rev-list -n10 -- {!@}', files)
                      | cmd.splitlines()):
        # ... gets last 10 commits touching `files`

You can also write filters directly, using the `@pysh.filter`
decorator.  See examples in the `example/` tree.  This is also the same
API that all the filters in `pysh.cmd` are built on, so there are many
examples there.