st-dynamodb-connection


Namest-dynamodb-connection JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://github.com/mrtj/st-dynamodb-connection
SummaryStreamlit Connection for Amazon DynamoDB.
upload_time2023-12-05 17:33:41
maintainer
docs_urlNone
authorJanos Tolgyesi
requires_python>=3.8, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*
licenseMIT
keywords streamlit dynamodb streamlit-connection
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Streamlit DynamoDB Connection

Streamlit DynamoDB Connection is a Python library that connects your Streamlit application to an Amazon DynamoDB table. This integration allows you to read and write persistent data in your table as simple as it were a Python dictionary. You can also visualize and edit the data from the user interface of your the application using an intuitive table widget.

[Streamlit](https://streamlit.io) is an open-source Python library that allows developers to create web applications for machine learning and data science projects quickly and easily.

[Amazon DynamoDB](https://aws.amazon.com/dynamodb/) is a fully managed NoSQL database service provided by [Amazon Web Services (AWS)](http://aws.amazon.com).

The primary method of data access in DynamoDB involves retrieving schema-less items by specifying their key, a process quite similar to the Python dictionary API. This library builds on the [dynamodb-mapping](https://github.com/mrtj/dynamodb-mapping) Python package that implements the dictionary interface over a DynamoDB table.

## Demo application

You can try the demo application of DynamoDB Connection at [https://st-dynamodb-connection.streamlit.app](https://st-dynamodb-connection.streamlit.app).

![Demo application](https://github.com/mrtj/st-dynamodb-connection/blob/main/docs/pandas_api.png?raw=true "Demo application")

## Getting started

### Installation

You can install DynamoDB Connections with pip:

```shell
pip install st-dynamodb-connection
```

### Creating a DynamoDB table and configuring AWS credentials

1. As Streamlit DynamoDB Connections connects your Streamlit application to a DynamoDB table, first you need a DynamoDB table. If you do not have already one, you can follow the steps in the [Create a DynamoDB table and add some data](./docs/create_table.md) document to create one.

2. You will also need to configure the AWS credentials for your Streamlit app. Follow the steps described in the [Create Access Key](https://docs.streamlit.io/knowledge-base/tutorials/databases/aws-s3#create-access-keys) section of the Connect Streamlit to AWS S3 page of the Streamlit documentation. You can also add the AWS credentials to the connection-specific section of your `secrets.toml`. For example, if you name your connection `my_dynamodb_connection`, you can add the following in the secrets file:

    ```conf
    # .streamlit/secrets.toml

    [connections.my_dynamodb_connection]
    table_name = "my_table"
    aws_access_key_id = "xxx"
    aws_secret_access_key = "xxx"
    aws_region = "eu-west-1"
    ```

    Ensure you change the values to the actual value of your credentials, AWS region and table name.

### Using DynamoDB Connection

You can use DynamoDB Connection in your Streamlit application as simple as:

```python
import streamlit as st
from dynamodb_connection import DynamoDBConnection

# Create a connection:
conn = st.connection(
    "my_dynamodb_connection", type=DynamoDBConnection, api_type="pandas"
)

# Get all items in the table:
st.write(conn.items())

# Get a single item by key:
item = conn.get_item("first_item")
st.write(item)

# Put an item in the table:
conn.put_item(
    "new_item",
    {
        "text": "This item was put from streamlit!",
        "metadata": {"source": "mrtj"},
    }
)

# Modify an existing item:
conn.modify_item(
    "new_item",
    {
        "text": "This item was put and modified from streamlit!",
        "metadata": None,
        "new_field": "This is a newly added field"
    }
)

# Delete an item from the table:
conn.del_item("new_item")
```

### API variants

The previous examples used the `pandas` API of DynamoDB Connections. In this mode the connection will return Pandas objects (`DataFrame`s or `Series`). You can also use the `raw` API to get the results as standard Python objects (lists and dictionaries).

DynamoDB Connections also lets you access the underlying [DynamoDB Mapping](https://github.com/mrtj/dynamodb-mapping) instance that lets you use your table as if it were a Python Dictionary. For more information, check the [Dictionary API](examples/pages/3_Dictionary_API.py) sample application.

### Table editor

DynamoDB Connections comes with an integration with [Streamlit Data Editor](https://docs.streamlit.io/library/api-reference/data/st.data_editor) called Table Editor. This widget displays all items in your DynamoDB table in an editable way. Your modifications are written to back to the DynamoDB table on the fly, allowing you (or the users of your app) to modify the data in the table in a convenient way. You can try out the table editor in the [Demo application](#demo-application).

Example usage:

```python
import streamlit as st
from dynamodb_connection import DynamoDBConnection

# Create a connection:
conn = st.connection(
    "my_dynamodb_connection", type=DynamoDBConnection, api_type="pandas"
)

# Launch the table editor:
table_editor = DynamoDBTableEditor(conn)
table_editor.edit()
```

![Table editor](https://github.com/mrtj/st-dynamodb-connection/blob/main/docs/table_editor.png?raw=true "Table editor")

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mrtj/st-dynamodb-connection",
    "name": "st-dynamodb-connection",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*",
    "maintainer_email": "",
    "keywords": "streamlit,dynamodb,streamlit-connection",
    "author": "Janos Tolgyesi",
    "author_email": "janos.tolgyesi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/03/7d/52d920f67a629cbb4e045b89de5fa02614ae2f7f29ffb16bfb45315785bd/st_dynamodb_connection-0.1.5.tar.gz",
    "platform": null,
    "description": "# Streamlit DynamoDB Connection\n\nStreamlit DynamoDB Connection is a Python library that connects your Streamlit application to an Amazon DynamoDB table. This integration allows you to read and write persistent data in your table as simple as it were a Python dictionary. You can also visualize and edit the data from the user interface of your the application using an intuitive table widget.\n\n[Streamlit](https://streamlit.io) is an open-source Python library that allows developers to create web applications for machine learning and data science projects quickly and easily.\n\n[Amazon DynamoDB](https://aws.amazon.com/dynamodb/) is a fully managed NoSQL database service provided by [Amazon Web Services (AWS)](http://aws.amazon.com).\n\nThe primary method of data access in DynamoDB involves retrieving schema-less items by specifying their key, a process quite similar to the Python dictionary API. This library builds on the [dynamodb-mapping](https://github.com/mrtj/dynamodb-mapping) Python package that implements the dictionary interface over a DynamoDB table.\n\n## Demo application\n\nYou can try the demo application of DynamoDB Connection at [https://st-dynamodb-connection.streamlit.app](https://st-dynamodb-connection.streamlit.app).\n\n![Demo application](https://github.com/mrtj/st-dynamodb-connection/blob/main/docs/pandas_api.png?raw=true \"Demo application\")\n\n## Getting started\n\n### Installation\n\nYou can install DynamoDB Connections with pip:\n\n```shell\npip install st-dynamodb-connection\n```\n\n### Creating a DynamoDB table and configuring AWS credentials\n\n1. As Streamlit DynamoDB Connections connects your Streamlit application to a DynamoDB table, first you need a DynamoDB table. If you do not have already one, you can follow the steps in the [Create a DynamoDB table and add some data](./docs/create_table.md) document to create one.\n\n2. You will also need to configure the AWS credentials for your Streamlit app. Follow the steps described in the [Create Access Key](https://docs.streamlit.io/knowledge-base/tutorials/databases/aws-s3#create-access-keys) section of the Connect Streamlit to AWS S3 page of the Streamlit documentation. You can also add the AWS credentials to the connection-specific section of your `secrets.toml`. For example, if you name your connection `my_dynamodb_connection`, you can add the following in the secrets file:\n\n    ```conf\n    # .streamlit/secrets.toml\n\n    [connections.my_dynamodb_connection]\n    table_name = \"my_table\"\n    aws_access_key_id = \"xxx\"\n    aws_secret_access_key = \"xxx\"\n    aws_region = \"eu-west-1\"\n    ```\n\n    Ensure you change the values to the actual value of your credentials, AWS region and table name.\n\n### Using DynamoDB Connection\n\nYou can use DynamoDB Connection in your Streamlit application as simple as:\n\n```python\nimport streamlit as st\nfrom dynamodb_connection import DynamoDBConnection\n\n# Create a connection:\nconn = st.connection(\n    \"my_dynamodb_connection\", type=DynamoDBConnection, api_type=\"pandas\"\n)\n\n# Get all items in the table:\nst.write(conn.items())\n\n# Get a single item by key:\nitem = conn.get_item(\"first_item\")\nst.write(item)\n\n# Put an item in the table:\nconn.put_item(\n    \"new_item\",\n    {\n        \"text\": \"This item was put from streamlit!\",\n        \"metadata\": {\"source\": \"mrtj\"},\n    }\n)\n\n# Modify an existing item:\nconn.modify_item(\n    \"new_item\",\n    {\n        \"text\": \"This item was put and modified from streamlit!\",\n        \"metadata\": None,\n        \"new_field\": \"This is a newly added field\"\n    }\n)\n\n# Delete an item from the table:\nconn.del_item(\"new_item\")\n```\n\n### API variants\n\nThe previous examples used the `pandas` API of DynamoDB Connections. In this mode the connection will return Pandas objects (`DataFrame`s or `Series`). You can also use the `raw` API to get the results as standard Python objects (lists and dictionaries).\n\nDynamoDB Connections also lets you access the underlying [DynamoDB Mapping](https://github.com/mrtj/dynamodb-mapping) instance that lets you use your table as if it were a Python Dictionary. For more information, check the [Dictionary API](examples/pages/3_Dictionary_API.py) sample application.\n\n### Table editor\n\nDynamoDB Connections comes with an integration with [Streamlit Data Editor](https://docs.streamlit.io/library/api-reference/data/st.data_editor) called Table Editor. This widget displays all items in your DynamoDB table in an editable way. Your modifications are written to back to the DynamoDB table on the fly, allowing you (or the users of your app) to modify the data in the table in a convenient way. You can try out the table editor in the [Demo application](#demo-application).\n\nExample usage:\n\n```python\nimport streamlit as st\nfrom dynamodb_connection import DynamoDBConnection\n\n# Create a connection:\nconn = st.connection(\n    \"my_dynamodb_connection\", type=DynamoDBConnection, api_type=\"pandas\"\n)\n\n# Launch the table editor:\ntable_editor = DynamoDBTableEditor(conn)\ntable_editor.edit()\n```\n\n![Table editor](https://github.com/mrtj/st-dynamodb-connection/blob/main/docs/table_editor.png?raw=true \"Table editor\")\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Streamlit Connection for Amazon DynamoDB.",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://github.com/mrtj/st-dynamodb-connection",
        "Repository": "https://github.com/mrtj/st-dynamodb-connection"
    },
    "split_keywords": [
        "streamlit",
        "dynamodb",
        "streamlit-connection"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b4336c2a18693c6ee33ac507b80a755004c92ac6262f3d38660f63e9676e5954",
                "md5": "34438a608d75e7b70d10300389ad998f",
                "sha256": "6940257f5cf59a6f01bcbb8d413cf873d5889a7e4d1dac709dbaa58da70ebb79"
            },
            "downloads": -1,
            "filename": "st_dynamodb_connection-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "34438a608d75e7b70d10300389ad998f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*",
            "size": 9442,
            "upload_time": "2023-12-05T17:33:39",
            "upload_time_iso_8601": "2023-12-05T17:33:39.444917Z",
            "url": "https://files.pythonhosted.org/packages/b4/33/6c2a18693c6ee33ac507b80a755004c92ac6262f3d38660f63e9676e5954/st_dynamodb_connection-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "037d52d920f67a629cbb4e045b89de5fa02614ae2f7f29ffb16bfb45315785bd",
                "md5": "3a073d40a9b3cd36a7c1d1ba8fb6625d",
                "sha256": "e1310ccdbc1e6788ab3312ab47937b0cfa94605dd6791b4563991e7e7a522959"
            },
            "downloads": -1,
            "filename": "st_dynamodb_connection-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "3a073d40a9b3cd36a7c1d1ba8fb6625d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*",
            "size": 9500,
            "upload_time": "2023-12-05T17:33:41",
            "upload_time_iso_8601": "2023-12-05T17:33:41.222926Z",
            "url": "https://files.pythonhosted.org/packages/03/7d/52d920f67a629cbb4e045b89de5fa02614ae2f7f29ffb16bfb45315785bd/st_dynamodb_connection-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-05 17:33:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mrtj",
    "github_project": "st-dynamodb-connection",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "st-dynamodb-connection"
}
        
Elapsed time: 0.14482s