Skip to content

Latest commit

 

History

History
 
 

README.rst

Google Cloud Spanner: Bulk Loading From CSV Python Sample

Google Cloud Spanner is a highly scalable, transactional, managed, NewSQL database service.
Cloud Spanner solves the need for a horizontally-scaling database with consistent global transactions and SQL semantics.

This application demonstrates how to load data from a csv file into a Cloud Spanner database.

The data contained in the csv files is sourced from the "Hacker News - Y Combinator" Bigquery public dataset.

Pre-requisuite

Create a database in your Cloud Spanner instance using the schema in the folder.

Setup

Authentication

This sample requires you to have authentication setup. Refer to the Authentication Getting Started Guide for instructions on setting up credentials for applications.

Install Dependencies

  1. Install pip and virtualenv if you do not already have them. You may want to refer to the Python Development Environment Setup Guide for Google Cloud Platform for instructions.

  2. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.

    MACOS/LINUX

    $ virtualenv env
    $ source env/bin/activate

    WINDOWS

    > virtualenv env
    > .\env\Scripts\activate
  3. Install the dependencies needed to run the samples.

    $ pip install -r requirements.txt

To run sample

$ python batch_import.py instance_id database_id
positional arguments:

instance_id: Your Cloud Spanner instance ID.

database_id : Your Cloud Spanner database ID.