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
- 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.
-
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
-
Set Environment Variable:
Ensure the
SPANNER_EMULATOR_HOSTenvironment variable is set:export SPANNER_EMULATOR_HOST=localhost:9010
-
Create Test Instance and Database:
You need the
gcloudCLI 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
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b12dc4413949ed4d4999dc2911dd656f80fc4e0fa3a896c8c054e9bd131430e
|
|
| MD5 |
8447998c09bafb74866165ad99c51897
|
|
| BLAKE2b-256 |
0ff904e55c97b455781725f2c0273b01eef79b97c8900ddea97cc4e52f58dbe8
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spannerlib_python-0.1.0.tar.gz -
Subject digest:
2b12dc4413949ed4d4999dc2911dd656f80fc4e0fa3a896c8c054e9bd131430e - Sigstore transparency entry: 752610070
- Sigstore integration time:
-
Permalink:
googleapis/go-sql-spanner@a5cab15c6f7ace6980b0bfb7be9352b62f400fb8 -
Branch / Tag:
refs/heads/BRP-publish - Owner: https://github.com/googleapis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python-spanner-lib-wrapper.yml@a5cab15c6f7ace6980b0bfb7be9352b62f400fb8 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file spannerlib_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: spannerlib_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 79.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db2969d3a2afb02bcdacbe4131ebe05c6247be43472f5121d2d2fb4beb7610ef
|
|
| MD5 |
a65be6c56295e9e5f19c9e0d0f96901a
|
|
| BLAKE2b-256 |
da293dcf7816db16b366319fb3c66819c7f1c9864bb3c44c47901f167c81ba55
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spannerlib_python-0.1.0-py3-none-any.whl -
Subject digest:
db2969d3a2afb02bcdacbe4131ebe05c6247be43472f5121d2d2fb4beb7610ef - Sigstore transparency entry: 752610077
- Sigstore integration time:
-
Permalink:
googleapis/go-sql-spanner@a5cab15c6f7ace6980b0bfb7be9352b62f400fb8 -
Branch / Tag:
refs/heads/BRP-publish - Owner: https://github.com/googleapis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python-spanner-lib-wrapper.yml@a5cab15c6f7ace6980b0bfb7be9352b62f400fb8 -
Trigger Event:
workflow_dispatch
-
Statement type: