Skip to main content

Introduction

A Python module for managing Cloud Variables.

IMPORTANT NOTES

Since this module is built upon the package upstash-redis, you MUST visit the website right here to create tokens and the link that are nessecary for the following examples.

Examples:

Example 1 for the CloudVar class.

import cloud_variables as cv


cloudvar = cv.CloudVar("https://apparent-gopher-******.upstash.io", "******") # Use the actual values here.

# Basic assignment
cloudvar["string"] = "Hello, World!"

# Retrieving values
print(cloudvar["string"]) # 'Hello, World!'

# Advanced mutable objects
cloudvar["list"] = [1, 2, 3]
cloudvar["list"].append(4)

print(cloudvar["list"]) # [1, 2, 3, 4]

# Deleting and popping items
cloudvar["key1"] = "value1"
cloudvar["key2"] = "value2"

del cloudvar["key1"] # Deleting keys.
value = cloudvar.pop("key2") # Popping keys
print(value) # 'value2'

# Some more methods

# Retrieving Python key-value pairs as dictionaries
print(cloudvar.items()) # {'string': 'Hello, World!', 'list': [1, 2, 3, 4]}

# Clearing everything
cloudvar.clear()
print(cloudvar.items()) # {}

# Setting the client's data directly
cloudvar.set_dict({"key1": ["item1", "item2", "item3"], "key2": "value2", "key3": 3})
print(cloudvar.items()) # {'key1': ['item1', 'item2', 'item3'], 'key2': 'value2', 'key3': 3}

# __ior__
cloudvar |= {"key1": "value1", "key3": "value3"}
print(cloudvar.items()) # {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}

Example 2 for the class AsyncCloudVar.

import cloud_variables as cv
import asyncio


async def main(): # Use asynchronous functions for full functionality access.
    async_cloudvar = cv.AsyncCloudVar("https://apparent-gopher-******.upstash.io", "******") # Use your actual values again.
    async_cloudvar.start()

    # Basic assignment
    async_cloudvar["string"] = "Hello, World!"

    # Retrieving values
    print(async_cloudvar["string"]) # 'Hello, World!'

    # Advanced mutable objects
    async_cloudvar["list"] = [1, 2, 3]
    async_cloudvar["list"].append(4)

    print(async_cloudvar["list"]) # [1, 2, 3, 4]

    # Deleting and popping items
    async_cloudvar["key1"] = "value1"
    async_cloudvar["key2"] = "value2"

    del async_cloudvar["key1"] # Deleting keys.
    value = await async_cloudvar.pop("key2") # Popping keys
    print(value) # 'value2'

    # Some more methods

    # Retrieving Python key-value pairs as dictionaries
    print(await async_cloudvar.items()) # {'string': 'Hello, World!', 'list': [1, 2, 3, 4]}

    # Clearing everything
    await async_cloudvar.clear()
    print(await async_cloudvar.items()) # {}

    # Setting the client's data directly
    await async_cloudvar.set_dict({"key1": ["item1", "item2", "item3"], "key2": "value2", "key3": 3})
    print(await async_cloudvar.items()) # {'key1': ['item1', 'item2', 'item3'], 'key2': 'value2', 'key3': 3}
    
    # __ior__
    async_cloudvar |= {"key1": "value1", "key3": "value3"}
    print(await async_cloudvar.items()) # {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}

asyncio.run(main())

Installation

You can easily install the module by typing the command:

pip install cloud-python-vars

Metadata

Release files for cloud-python-vars 0.2.1

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

Source distribution (sdist)

Source distribution for cloud-python-vars 0.2.1
File Size Uploaded
cloud_python_vars-0.2.1.tar.gz 17.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cloud-python-vars 0.2.1
File Interpreter ABI Platform
cloud_python_vars-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 35.7 kB

Release files / cloud_python_vars-0.2.1.tar.gz

Download URL cloud_python_vars-0.2.1.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e8b7665f14e1149ce01c75ecd5dc47e8d409eae6015ee99944b9fe3d34288ccb
BLAKE2b-256 checksum
How to use checksums
8bbba1c43b91190aa31ff68bb9291d6afc82e6602b0634ec45c9bccd57a14031
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / cloud_python_vars-0.2.1-py3-none-any.whl

Download URL cloud_python_vars-0.2.1-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4ab5d22b08d867c76a7b2b7da0f665a528b4d2e7f46eea83f49354362b774f9
BLAKE2b-256 checksum
How to use checksums
f3ec0e7746e1cfe5bf3474cd2d4693be201a5cba497f3d03304bacd04fae0c27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.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