aioradio


Nameaioradio JSON
Version 0.20.18 PyPI version JSON
download
home_pagehttps://github.com/nrccua/aioradio
SummaryGeneric asynchronous i/o python utilities for AWS services (SQS, S3, DynamoDB, Secrets Manager), Redis, MSSQL (pyodbc), JIRA and more
upload_time2024-04-06 22:52:17
maintainerNone
docs_urlNone
authorEncoura DS Team
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # aioradio
Generic asynchronous i/o python utilities for AWS services (SQS, S3, DynamoDB, Secrets Manager), Redis, MSSQL (pyodbc), JIRA and more.

## AWS S3 example code
aioradio abstracts using aiobotocore and aioboto3 making async AWS funtion calls simple one liners.
Besides what is shown below in the examples, there is also support for SQS, DynamoDB and Secrets Manager.


```python
import asyncio

from aioradio.aws.s3 import (
    create_bucket,
    delete_s3_object,
    download_file,
    get_object,
    list_s3_objects,
    upload_file
)

async def main():
    s3_bucket = 'aioradio'
    s3_prefix = 'test'
    filename = 'hello_world.txt'
    s3_key = f'{s3_prefix}/{filename}'

    # create an s3 bucket called aioradio
    await create_bucket(bucket=s3_bucket)

    # create hello_world.txt file
    with open(filename, 'w') as file_handle:
        file_handle.write('hello world of aioradio!')

    # upload the file from s3 and confirm it now exists in s3
    await upload_file(bucket=s3_bucket, filepath=filename, s3_key=s3_key)
    assert s3_key in await list_s3_objects(bucket=s3_bucket, s3_prefix=s3_prefix)

    # test downloading the file
    await download_file(bucket=s3_bucket, filepath=filename, s3_key=s3_key)

    # test getting file data to object
    result = await get_object(bucket=s3_bucket, s3_key=s3_key)
    assert result == b'hello world of aioradio!'

    # delete the file from s3
    await delete_s3_object(bucket=s3_bucket, s3_prefix=s3_key)
    assert s3_key not in await list_s3_objects(bucket=s3_bucket, s3_prefix=s3_prefix)

asyncio.get_event_loop().run_until_complete(main())
```

## MSSQL example code
aioredis uses the pyodbc library to work with ODBC databases.
It currently has support for connecting and sending queries to mssql.

```python
import asyncio

from aioradio.pyodbc import establish_pyodbc_connection
from aioradio.pyodbc import pyodbc_query_fetchone
from aioradio.pyodbc import pyodbc_query_fetchall

def main():
    conn = establish_pyodbc_connection(host='your-host', user='your-user', pwd='your-password')

    query = "SELECT homeruns FROM MLB.dbo.LosAngelesAngels WHERE lastname = 'Trout' AND year = '2020'"
    row = pyodbc_query_fetchone(conn=conn, query=query)
    print(row)

    query = "SELECT homeruns FROM MLB.dbo.LosAngelesAngels WHERE lastname = 'Trout'"
    rows = pyodbc_query_fetchall(conn=conn, query=query)
    print(rows)


asyncio.get_event_loop().run_until_complete(main())
```

## Jira example code
Jira uses the async library httpx behind the scene to send http requests.

```python
import asyncio

from aioradio.jira import add_comment_to_jira
from aioradio.jira import get_jira_issue
from aioradio.jira import post_jira_issue

async def main():

    # create a jira ticket
    url = 'https://aioradio.atlassian.net/rest/api/2/issue/'
    payload = {
        "fields": {
            "project": {"key": "aioradio"},
            "issuetype": {"name": "Task"},
            "reporter": {"accountId": "somebodies-account-id"},
            "priority": {"name": "Medium"},
            "summary": "Aioradio rocks!",
            "description": "Aioradio Review",
            "labels": ["aioradio"],
            "assignee": {"accountId": "somebodies-account-id"}
        }
    }
    resp = await post_jira_issue(url=url, jira_user='your-user', jira_token='your-password', payload=payload)
    jira_id = resp.json()['key']

    # get jira ticket info
    resp = await get_jira_issue(url=f'{url}/{jira_id}', jira_user='your-user', jira_token='your-password')

    # add comment to jira ticket
    comment = 'aioradio rocks!'
    response = await add_comment_to_jira(url=url, jira_user='your-user', jira_token='your-password', comment=comment)

asyncio.get_event_loop().run_until_complete(main())
```

## INSTALLING FOR DIRECT DEVELOPMENT OF AIORADIO

Install [python 3.11.X](https://www.python.org/downloads/)

Make sure you've installed [ODBC drivers](https://docs.microsoft.com/en-us/sql/connect/python/pyodbc/step-1-configure-development-environment-for-pyodbc-python-development), required for using the python package pyodbc.

Clone aioradio locally and navigate to the root directory

Install and activate python VirtualEnv
```bash
python3.11 -m venv env
source env/bin/activate
```

Install python modules included in requirements.txt
```bash
pip install cython
pip install -r aioradio/requirements.txt
```

Run Makefile command from the root directory to test all is good before issuing push to master
```
make all
```

## AUTHORS

* **Tim Reichard** - [aioradio](https://github.com/nrccua/aioradio)

See also the list of [contributors](https://github.com/nrccua/aioradio/graphs/contributors) who participated in this project.

## ACKNOWLEDGEMENTS

* **Pedro Artiga** - Developer contributing to aioradio.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nrccua/aioradio",
    "name": "aioradio",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Encoura DS Team",
    "author_email": "tim.reichard@encoura.org",
    "download_url": "https://files.pythonhosted.org/packages/17/11/3513c82ae76a043ec10e584f4c508a8a082f029d2f60327809daa8c2e9f1/aioradio-0.20.18.tar.gz",
    "platform": null,
    "description": "# aioradio\nGeneric asynchronous i/o python utilities for AWS services (SQS, S3, DynamoDB, Secrets Manager), Redis, MSSQL (pyodbc), JIRA and more.\n\n## AWS S3 example code\naioradio abstracts using aiobotocore and aioboto3 making async AWS funtion calls simple one liners.\nBesides what is shown below in the examples, there is also support for SQS, DynamoDB and Secrets Manager.\n\n\n```python\nimport asyncio\n\nfrom aioradio.aws.s3 import (\n    create_bucket,\n    delete_s3_object,\n    download_file,\n    get_object,\n    list_s3_objects,\n    upload_file\n)\n\nasync def main():\n    s3_bucket = 'aioradio'\n    s3_prefix = 'test'\n    filename = 'hello_world.txt'\n    s3_key = f'{s3_prefix}/{filename}'\n\n    # create an s3 bucket called aioradio\n    await create_bucket(bucket=s3_bucket)\n\n    # create hello_world.txt file\n    with open(filename, 'w') as file_handle:\n        file_handle.write('hello world of aioradio!')\n\n    # upload the file from s3 and confirm it now exists in s3\n    await upload_file(bucket=s3_bucket, filepath=filename, s3_key=s3_key)\n    assert s3_key in await list_s3_objects(bucket=s3_bucket, s3_prefix=s3_prefix)\n\n    # test downloading the file\n    await download_file(bucket=s3_bucket, filepath=filename, s3_key=s3_key)\n\n    # test getting file data to object\n    result = await get_object(bucket=s3_bucket, s3_key=s3_key)\n    assert result == b'hello world of aioradio!'\n\n    # delete the file from s3\n    await delete_s3_object(bucket=s3_bucket, s3_prefix=s3_key)\n    assert s3_key not in await list_s3_objects(bucket=s3_bucket, s3_prefix=s3_prefix)\n\nasyncio.get_event_loop().run_until_complete(main())\n```\n\n## MSSQL example code\naioredis uses the pyodbc library to work with ODBC databases.\nIt currently has support for connecting and sending queries to mssql.\n\n```python\nimport asyncio\n\nfrom aioradio.pyodbc import establish_pyodbc_connection\nfrom aioradio.pyodbc import pyodbc_query_fetchone\nfrom aioradio.pyodbc import pyodbc_query_fetchall\n\ndef main():\n    conn = establish_pyodbc_connection(host='your-host', user='your-user', pwd='your-password')\n\n    query = \"SELECT homeruns FROM MLB.dbo.LosAngelesAngels WHERE lastname = 'Trout' AND year = '2020'\"\n    row = pyodbc_query_fetchone(conn=conn, query=query)\n    print(row)\n\n    query = \"SELECT homeruns FROM MLB.dbo.LosAngelesAngels WHERE lastname = 'Trout'\"\n    rows = pyodbc_query_fetchall(conn=conn, query=query)\n    print(rows)\n\n\nasyncio.get_event_loop().run_until_complete(main())\n```\n\n## Jira example code\nJira uses the async library httpx behind the scene to send http requests.\n\n```python\nimport asyncio\n\nfrom aioradio.jira import add_comment_to_jira\nfrom aioradio.jira import get_jira_issue\nfrom aioradio.jira import post_jira_issue\n\nasync def main():\n\n    # create a jira ticket\n    url = 'https://aioradio.atlassian.net/rest/api/2/issue/'\n    payload = {\n        \"fields\": {\n            \"project\": {\"key\": \"aioradio\"},\n            \"issuetype\": {\"name\": \"Task\"},\n            \"reporter\": {\"accountId\": \"somebodies-account-id\"},\n            \"priority\": {\"name\": \"Medium\"},\n            \"summary\": \"Aioradio rocks!\",\n            \"description\": \"Aioradio Review\",\n            \"labels\": [\"aioradio\"],\n            \"assignee\": {\"accountId\": \"somebodies-account-id\"}\n        }\n    }\n    resp = await post_jira_issue(url=url, jira_user='your-user', jira_token='your-password', payload=payload)\n    jira_id = resp.json()['key']\n\n    # get jira ticket info\n    resp = await get_jira_issue(url=f'{url}/{jira_id}', jira_user='your-user', jira_token='your-password')\n\n    # add comment to jira ticket\n    comment = 'aioradio rocks!'\n    response = await add_comment_to_jira(url=url, jira_user='your-user', jira_token='your-password', comment=comment)\n\nasyncio.get_event_loop().run_until_complete(main())\n```\n\n## INSTALLING FOR DIRECT DEVELOPMENT OF AIORADIO\n\nInstall [python 3.11.X](https://www.python.org/downloads/)\n\nMake sure you've installed [ODBC drivers](https://docs.microsoft.com/en-us/sql/connect/python/pyodbc/step-1-configure-development-environment-for-pyodbc-python-development), required for using the python package pyodbc.\n\nClone aioradio locally and navigate to the root directory\n\nInstall and activate python VirtualEnv\n```bash\npython3.11 -m venv env\nsource env/bin/activate\n```\n\nInstall python modules included in requirements.txt\n```bash\npip install cython\npip install -r aioradio/requirements.txt\n```\n\nRun Makefile command from the root directory to test all is good before issuing push to master\n```\nmake all\n```\n\n## AUTHORS\n\n* **Tim Reichard** - [aioradio](https://github.com/nrccua/aioradio)\n\nSee also the list of [contributors](https://github.com/nrccua/aioradio/graphs/contributors) who participated in this project.\n\n## ACKNOWLEDGEMENTS\n\n* **Pedro Artiga** - Developer contributing to aioradio.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Generic asynchronous i/o python utilities for AWS services (SQS, S3, DynamoDB, Secrets Manager), Redis, MSSQL (pyodbc), JIRA and more",
    "version": "0.20.18",
    "project_urls": {
        "Homepage": "https://github.com/nrccua/aioradio"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a0f063fe7507dd9c66bd9d550c2d360bea6c1d7d7a255339208240e416482406",
                "md5": "a973f25e1b9dde659c4908caaacc9c28",
                "sha256": "3712f7669c54be1b506a2b48d241b513faa7110b2b91cd84fbd5a7ed720c1362"
            },
            "downloads": -1,
            "filename": "aioradio-0.20.18-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a973f25e1b9dde659c4908caaacc9c28",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 37021,
            "upload_time": "2024-04-06T22:52:14",
            "upload_time_iso_8601": "2024-04-06T22:52:14.345909Z",
            "url": "https://files.pythonhosted.org/packages/a0/f0/63fe7507dd9c66bd9d550c2d360bea6c1d7d7a255339208240e416482406/aioradio-0.20.18-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "17113513c82ae76a043ec10e584f4c508a8a082f029d2f60327809daa8c2e9f1",
                "md5": "dd5b74be38816de5202e66154ba194de",
                "sha256": "0c87b68388b9a1562847733b24bdae070b8c8abcfc49292388744e2b8143afe4"
            },
            "downloads": -1,
            "filename": "aioradio-0.20.18.tar.gz",
            "has_sig": false,
            "md5_digest": "dd5b74be38816de5202e66154ba194de",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 33464,
            "upload_time": "2024-04-06T22:52:17",
            "upload_time_iso_8601": "2024-04-06T22:52:17.023629Z",
            "url": "https://files.pythonhosted.org/packages/17/11/3513c82ae76a043ec10e584f4c508a8a082f029d2f60327809daa8c2e9f1/aioradio-0.20.18.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-06 22:52:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nrccua",
    "github_project": "aioradio",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "aioradio"
}
        
Elapsed time: 0.23970s