Skip to main content

jblib-aws

Author: Justin Bard

This module was written to minimize the need to write the functions I use often.

INSTALL: python3 -m pip install jblibaws


The source code can be viewed here: https://github.com/ANamelessDrake/jblib-aws

More of my projects can be found here: http://justbard.com


talk_with_dynamo

A class that provides functionality for interacting with AWS DynamoDB tables. It allows you to perform various operations like querying, getting items, updating, inserting, deleting, and scanning the table.

class talk_with_dynamo(table, boto_session, region='us-east-1')

Example:
    table_name = "table-name"
    boto_session = boto3.session.Session()
    dynamo = talk_with_dynamo(table_name, boto_session) # Generate Database Object

    response = dynamo.query(partition_key=None, partition_key_attribute=None, sorting_key=False, 
			sorting_key_attribute=False, index=False, queryOperator=False, 
			betweenValue=False, keyConditionExpression=None, scanIndexForward=True, limit=None):
    print("Response: {}".format(response))

    getResponse = dynamo.getItem(partition_key, partition_key_attribute, sorting_key=False, sorting_key_attribute=False)

    batch_keys = {'tableName': {'Keys': [{'PartitionKey': 'PartitionKeyAttribute', 'SortingKey': 'SortingKey'}]}}
    batchResponse = dynamo.batchGetItem(batch_keys)

    insert_response = dynamo.insert(json_object)
    print("Insert Response: {}".format(insert_response))

    update_response = dynamo.update(partition_key_attribute, sorting_key_attribute, update_key, update_attribute)

    update_response = dynamo.updateV2(partition_key_attribute, update_key, update_attribute, sorting_key_attribute=None,
				conditionExpression=None, conditionCheck=None, sorting_key=None, max_tries=5, 
				additionalUpdateExpressions=None, expressionAttributeValues=None, 
				expressionAttributeNames=None, returnValues="UPDATED_NEW"):

    delete_response = dynamo.delete(partition_key_attribute, sorting_key_attribute=False, sorting_key=None, partition_key=None)

    scan_results = dynamo.scan(filter_expression=None, expression_attribute_values=None, max_pages=None)

    get_table_description = dynamo.getTableDescription()

    dynamo.clearTable() # Delete all entries in a table -- Use with caution

extractDynamoDBData

Extracts and cleans data from a payload retrieved from DynamoDB.

Parameters:

  • payload (dict): The payload containing data retrieved from DynamoDB as a dictionary.
  • record (str): The key to access a specific piece of data within the payload.
  • dataType (str, optional): The type of data to retrieve. Default is "S" (string).

Returns:

  • str or int or False: The extracted and cleaned data based on the specified record and dataType.
  • Returns False if the specified record is not found, or if there is an error during data extraction.
function extractDynamoDBData(payload, record, dataType="S")

Example:
    payload = {
        "name": "John Doe",
        "age": {
            "N": "30"
        },
        "address": "123 Main Street"
    }
    data = returnData(payload, "name")
    print(data)  # Output: "John Doe"

    data = returnData(payload, "age", dataType="N")
    print(data)  # Output: 30

    data = returnData(payload, "email")
    print(data)  # Output: False (record not found in payload)

talk_with_cognito

A class that provides functionality for interacting with AWS Cognito. It allows you to get a user's email address using their Cognito user ID.

    class talk_with_cognito(boto_client, cognito_user_pool_id)

        Example:

        Functions:
            get_user_email(cognito_user_id)
            - Gets User Email Address

get_secret

A function that retrieves a decoded secret from AWS Secrets Manager.

    function get_secret(secret_name, region='us-east-1')

        Example:

        Functions:
            get_secret(secret_name)
            - Returns decoded secret from AWS Secrets Manager

Metadata

Release files for jblibaws 1.2.80

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

Source distribution (sdist)

Source distribution for jblibaws 1.2.80
File Size Uploaded
jblibaws-1.2.80.tar.gz 9.9 kB Details

Built distribution (wheel)

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

Total release size: 20.6 kB

Release files / jblibaws-1.2.80.tar.gz

Download URL jblibaws-1.2.80.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b5f02d868922e449441ba6821f4bb9d8fbf4419069367d24d7e99b48841abbde
BLAKE2b-256 checksum
How to use checksums
5874303998b80379039fa179a6a61b8b34af06d0319adb4b5aceaead40424cfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / jblibaws-1.2.80-py3-none-any.whl

Download URL jblibaws-1.2.80-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c843c6ea99b321d4d02e60000dded3065879491f028f6f6822b08af5561cbbc6
BLAKE2b-256 checksum
How to use checksums
bedd80127b98292b85bd00e7a8d5a1b540cc7db8a4e2252ba4e4f7ea35b696b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

1.2.80 This release

2 release files

1.2.73

2 release files

1.2.72

2 release files

1.2.71

2 release files

1.2.8

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2

2 release files

1.1.1

2 release files

1.1

2 release files

1.0.19

2 release files

1.0.18

2 release files

1.0.17

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0

1 release file

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