RHDZMOTA / spanner-utils

Command-line interface written in python to handle basic spanner operations.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spanner Utils

Command-line interface to perform basic spanner operations.

Requirements

  • Python 3.x
  • gcloud

Setup and install

Setup your gcloud stuff:

  • Install the google cloud sdk.
  • Authenticate: gcloud auth login
  • Set the project: gcloud config set project [PROJECT_ID]

Now install the repo:

  1. Clone this repo.
  2. Install the requirements: pip install -r requirements
  3. [Optional] Add to your profile (.rc) file with an alias: alias spanner=python path/to/this/repo/main.py

Usage

Import csv-files to spanner

To import a csv-file run the following:

spanner --instance_id [INSTANCE_ID] --database_id [DATABASE_ID] --table_id [TABLE_ID] --file_path [FILE_PATH] --format_path [FORMAT_PATH] --chunksize [CHUNKSIZE]

Where:

    INSTANCE_ID : Cloud Spanner instance id.
    DATABASE_ID : Cloud Spanner database id.
    TABLE_ID    : Cloud Spanner table id.
    FILE_PATH   : Cloud Spanner path to csv file (note that headers are required).
    FORMAT_PATH : JSON file that contains the dtype info e.g. {"STRING_COL": "object", "INT64_COL": "int64"}.
    CHUNKSIZE   : Number of lines to read per upload (use -1 to read the file in one iteration, recommended: 1000). 

Download csv-files from spanner

Not available.

Create/Delete spanner elements

Not available.

Authors

LICENSE

Creative Commons License
spanner-utils by Rodrigo Hernández Mota is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Acknowledgements

Not so far.

About

Command-line interface written in python to handle basic spanner operations.


Languages

Language:Python 100.0%