Splitgraph has been acquired by EDB! Read the blog post.

splitgraph.commandline package

Submodules

splitgraph.commandline.cloud module

Command line routines related to registering/setting up connections to the Splitgraph registry.

splitgraph.commandline.cloud.wait_for_download(client: GQLAPIClient, task_id: str) str
splitgraph.commandline.cloud.wait_for_load(client: GQLAPIClient, namespace: str, repository: str, task_id: str) None

splitgraph.commandline.common module

Various common functions used by the command line interface.

class splitgraph.commandline.common.ImageType(default: Optional[str] = 'latest', repository_exists: bool = False, get_image: bool = False)

Bases: click.types.ParamType

Parser that extracts the full image specification (repository and hash/tag).

convert(value: str, param: Optional[click.core.Parameter], ctx: Optional[click.core.Context]) Tuple[Repository, Optional[Union[Image, str]]]

Image specification must have the format [NAMESPACE/]REPOSITORY[:HASH_OR_TAG].

The parser returns a tuple of (repository object, tag or hash).

name = 'Image'

the descriptive name of this type

class splitgraph.commandline.common.JsonType

Bases: click.types.ParamType

Parser for Json – a wrapper around json.loads because without specifying the name Click shows the type for the option/arg as LOADS.

Also supports passing JSON files (pass in @filename.json).

convert(value: str, param: Optional[click.core.Parameter], ctx: Optional[click.core.Context])

Converts the value. This is not invoked for values that areNone (the missing value).

name = 'Json'

the descriptive name of this type

class splitgraph.commandline.common.RepositoryType(exists: bool = False)

Bases: click.types.ParamType

convert(value: str, param: Optional[click.core.Parameter], ctx: Optional[click.core.Context]) Repository

Converts the value. This is not invoked for values that areNone (the missing value).

name = 'Repository'

the descriptive name of this type

splitgraph.commandline.common.download_file(url: str, filename: Optional[str]) None

Download a file with a tqdm progress bar

splitgraph.commandline.common.emit_sql_results(results, use_json=False, show_all=False)
splitgraph.commandline.common.get_spinner_settings() Tuple[Iterator[str], int]
splitgraph.commandline.common.load_json_param(value: str, param: Optional[click.core.Parameter], ctx: Optional[click.core.Context])
splitgraph.commandline.common.remote_switch_option(*names, **kwargs)

Adds an option to switch global SG_ENGINE for this invocation of sgr.

This is useful for e.g. tagging or viewing image information on a remote registry. This is not used in operations like commit/checkout (even though nothing is preventing SG_ENGINE switch from working on that if the remote engine supports this), the user should switch SG_ENGINE envvar themselves in that case.

Parameters
  • names – Names

  • kwargs – Passed to click.option

splitgraph.commandline.common.sql_results_to_str(results: List[Tuple[Any]], use_json: bool = False) str
splitgraph.commandline.common.upload_file(file: IO, upload_url: str) None

Upload a file to a presigned URL with a tqdm progress bar

splitgraph.commandline.common.wait_for_job(task_id: str, status_callback: Callable[[], Optional[splitgraph.commandline.common.S]]) splitgraph.commandline.common.S

Wait for a job to complete (with a CLI spinner) and return its final result.

Parameters
  • task_id – ID of the task (used for display)

  • status_callback – Callback that returns a JobStatus

Returns

Final JobStatus

splitgraph.commandline.engine module

splitgraph.commandline.engine.inject_config_into_engines(engine_prefix, config_path)

Copy the current config into all engines that are managed by sgr engine. This is so that the engine has the right credentials and settings for when we do layered querying (a Postgres client queries the engine directly and it has to download objects etc).

Parameters
  • engine_prefix – Prefix for Docker containers that are considered to be engines

  • config_path – Path to the config file.

splitgraph.commandline.engine.list_engines(prefix, include_all=False, unavailable_ok=True)

splitgraph.commandline.example module

Command line routines generating example data / Splitfiles

splitgraph.commandline.example.alter_table(repository: Repository, table_name: str, rows_added: int, rows_deleted: int, rows_updated: int) None

Alters the example table, adding/updating/deleting a certain number of rows.

Parameters
  • repository – Checked-out Repository object.

  • table_name – Name of the table

  • rows_added – Number of rows to add

  • rows_deleted – Number of rows to remove

  • rows_updated – Number of rows to update

splitgraph.commandline.example.generate_table(repository: Repository, table_name: str, size: int) None

Creates a table with an integer primary key and a string value.

Parameters
  • repository – Checked-out Repository to create the table in.

  • table_name – Name of the table to generate

  • size – Number of rows in the table.

splitgraph.commandline.image_creation module

sgr commands related to creating and checking out images

splitgraph.commandline.image_info module

sgr commands related to getting information out of / about images

splitgraph.commandline.ingestion module

Command line tools for ingesting/exporting Splitgraph images into other formats.

splitgraph.commandline.misc module

Miscellaneous image management sgr commands.

splitgraph.commandline.mount module

sgr commands related to mounting databases via Postgres FDW

splitgraph.commandline.push_pull module

sgr commands related to sharing and downloading images.

splitgraph.commandline.splitfile module

sgr commands related to building and rebuilding Splitfiles.

Module contents

Splitgraph command line client

Hooks into the API to allow management of Splitgraph repositories and images using sgr.

class splitgraph.commandline.ClickHandler(level=0)

Bases: logging.Handler

emit(record)

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

class splitgraph.commandline.WithExceptionHandler(name=None, commands=None, **attrs)

Bases: click.core.Group

get_command(ctx, cmd_name)

Given a context and a command name, this returns aCommand object if it exists or returns None.

invoke(ctx)

Given a context, this invokes the attached callback (if it exists) in the right way.