Skip to main content

A Python wrapper for the Go spannerlib. This is an internal library that can make breaking changes without prior notice.

Project description

SPANNERLIB-PYTHON: A High-Performance Python Wrapper for the Go Spanner Client Shared lib

NOTICE: This is an internal library that can make breaking changes without prior notice.

Introduction

The spannerlib-python wrapper provides a high-performance, idiomatic Python interface for Google Cloud Spanner by wrapping the official Go Client Shared library.

The Go library is compiled into a C-shared library, and this project calls it directly from Python, aiming to combine Go's performance with Python's ease of use.

Code Structure

spannerlib-python/
|___google/cloud/spannerlib/
    |___internal - SpannerLib wrapper
        |___lib - Spannerlib artifacts
|___tests/
    |___unit/ - Unit tests
    |___system/ - System tests
|___samples
README.md
noxfile.py
pyproject.toml - Project config for packaging

NOX Setup

  1. Create virtual environment

Mac/Linux

pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate

Windows

pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate

Install Dependencies

pip install -r requirements.txt

To run the nox tests, navigate to the root directory of this wrapper (spannerlib-python) and run:

format/Lint

nox -s format lint

Unit Tests

nox -s unit

Run specific tests

# file
nox -s unit-3.13 -- tests/unit/test_connection.py
# class
nox -s unit-3.13 -- tests/unit/test_connection.py::TestConnection
# method
nox -s unit-3.13 -- tests/unit/test_connection.py::TestConnection::test_close_connection_propagates_error

System Tests

The system tests require a Cloud Spanner Emulator instance running.

  1. Pull and Run the Emulator:

    docker pull gcr.io/cloud-spanner-emulator/emulator
    docker run -p 9010:9010 -p 9020:9020 -d gcr.io/cloud-spanner-emulator/emulator
    
  2. Set Environment Variable:

    Ensure the SPANNER_EMULATOR_HOST environment variable is set:

    export SPANNER_EMULATOR_HOST=localhost:9010
    
  3. Create Test Instance and Database:

    You need the gcloud CLI installed and configured.

    gcloud spanner instances create test-instance --config=emulator-config --description="Test Instance" --nodes=1
    gcloud spanner databases create testdb --instance=test-instance
    
  4. Run the System Tests:

    nox -s system
    

Build and install

Package

Create python wheel

pip3 install build
python3 -m build

Validate Package

pip3 install twine
twine check dist/*
unzip -l dist/spannerlib-*-*.whl
tar -tvzf dist/spannerlib-*.tar.gz

Install locally

pip3 install -e .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spannerlib_python-0.1.0.tar.gz (78.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spannerlib_python-0.1.0-py3-none-any.whl (79.2 MB view details)

Uploaded Python 3

File details

Details for the file spannerlib_python-0.1.0.tar.gz.

File metadata

  • Download URL: spannerlib_python-0.1.0.tar.gz
  • Upload date:
  • Size: 78.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spannerlib_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2b12dc4413949ed4d4999dc2911dd656f80fc4e0fa3a896c8c054e9bd131430e
MD5 8447998c09bafb74866165ad99c51897
BLAKE2b-256 0ff904e55c97b455781725f2c0273b01eef79b97c8900ddea97cc4e52f58dbe8

See more details on using hashes here.

Provenance

The following attestation bundles were made for spannerlib_python-0.1.0.tar.gz:

Publisher: release-python-spanner-lib-wrapper.yml on googleapis/go-sql-spanner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spannerlib_python-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for spannerlib_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db2969d3a2afb02bcdacbe4131ebe05c6247be43472f5121d2d2fb4beb7610ef
MD5 a65be6c56295e9e5f19c9e0d0f96901a
BLAKE2b-256 da293dcf7816db16b366319fb3c66819c7f1c9864bb3c44c47901f167c81ba55

See more details on using hashes here.

Provenance

The following attestation bundles were made for spannerlib_python-0.1.0-py3-none-any.whl:

Publisher: release-python-spanner-lib-wrapper.yml on googleapis/go-sql-spanner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page