Skip to main content

S1 Python

A barebones key-value store that requires no setup besides a token. This is the Python Library for S1. Find more information here

Getting A Token

Head over to s1.kognise.dev/token to get a token. Don't share this with anyone as it's your key to accessing all your data on your S1 DB. You can store this as an environment variable.

Installation

First, install S1 with pip:

$ pip install s1db

Then you can import it like so:

from s1db import S1

# Replace "your-token-here" with the token you got from the URL above.
api = S1("your-token-here")

Usage

Setting Objects as Values:

To set a Python object as a value use the S1.set() method.

api.set('keyname', 123)
api.set('keyname0', [23])
api.set('keyname1', {'foo': 'bar'})

The set method will automatically serialize your data for you into valid JSON to be stored on the S1 DB.

Getting An Object:

To get an object from your S1 DB use the S1.get() method.

api.get('keyname') # Returns: 123 based on the set example from above.
api.get('keyname0') # Returns: [23] as a list based on the set example from above.
api.get('keyname1') # Returns: {'foo': 'bar'} as a Python dict based on the set example from above.

Setting Raw Values:

To set a raw string as a value use the S1.set_raw() method.

api.set_raw('keyname-raw', '12')
api.set_raw('keyname-raw0, '{"foo": "bar"}')

The set_raw method does not do any JSON serialization and raw items cannot be returned with the get() method.

Getting Raw Values:

To get a raw value from a key use the S1.get_raw() method.

api.get_raw('keyname-raw') # Returns: 12 with no serialization
api.get_raw('ketname-raw0') # Returns: '{"foo": "bar"}' as string

Deleting Keys:

To delete data use the S1.delete() method.

api.delete('keyname')

Getting All Keys:

To get all your keys use the S1.get_keys() method.

api.get_keys() # Returns: List of key names as Python object.

Release files for s1db 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for s1db 1.0.3
File Size Uploaded
s1db-1.0.3.tar.gz 3.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for s1db 1.0.3
File Interpreter ABI Platform
s1db-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 6.1 kB

Release files / s1db-1.0.3.tar.gz

Download URL s1db-1.0.3.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f4a1bcb7135af13d4a6a7e8884b7dde03d2992a289120f423d7dcc6689b9e951
BLAKE2b-256 checksum
How to use checksums
efa52afb8b7f260fddf362146ea940ccdc050e71dfb4abaabeb7b09713847e51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.6.0 requests-toolbelt/0.8.0 tqdm/4.33.0 CPython/3.7.3

Release files / s1db-1.0.3-py3-none-any.whl

Download URL s1db-1.0.3-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eac85c5eba3a3ba2fa0409fef30b0615c16f7c11d9365640dc62b714e9514f92
BLAKE2b-256 checksum
How to use checksums
d503fe026f489c26b45576d16b5e8fa15c1c245787f7ae979c31903144aab703
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.6.0 requests-toolbelt/0.8.0 tqdm/4.33.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

3 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page