Sparta spanner library
Project description
sparta-spanner
Sparta Google Spanner library.
Usage
import os
import sparta.spanner
instance_id = os.getenv("INSTANCE_ID")
database_id = os.getenv("DATABASE_ID")
db_service = sparta.spanner.DBService(
instance_id=instance_id,
database_id=database_id,
pool_size=5,
session_request_timeout=2,
)
# Blocking
results = sparta.spanner.zip_results(db_service.execute_sql("SELECT 1 as my_field"))
assert results is not None
assert len(results) == 1
assert results[0] == {"my_field": 1}
# Non-Blocking
def task(snapshot):
result1 = sparta.spanner.zip_results(snapshot.execute_sql("SELECT 1 as my_field"))
result2 = sparta.spanner.zip_results(snapshot.execute_sql("SELECT 2 as my_field"))
return result1 + result2
results = await db_service.run_in_snapshot(task, multi_use=True)
assert results is not None
assert len(results) == 2
assert results[0] == {"my_field": 1}
assert results[1] == {"my_field": 2}
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
sparta-spanner-0.2.1.tar.gz
(6.7 kB
view hashes)
Built Distribution
Close
Hashes for sparta_spanner-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d077fc7b5f599530ce4dd00b1f7469b94ff2881f07aec00e929fad5c71bc9c6 |
|
MD5 | 121bffcd826c846ad6134bae4f0b8308 |
|
BLAKE2b-256 | f2e5909c7d01ac5b8f2b8984463a917ea8441364e2510ba0eb8fe2ece1ef0ca4 |