Dinamopy is a python helper library for dynamodb

Overview

Dinamopy

Dinamopy is a python helper library for dynamodb. You can define your access patterns in a json file and can use dynamic method names to make operations.

Installation

Use the package manager pip to install dinamopy.

pip install dinamopy

Usage

app.py

from decimal import Decimal
import dinamopy


class MyHooks(dinamopy.DinamoHooks):
    def after_get(self, response):
        for k, v in response.items():
            if isinstance(v, Decimal):
                response[k] = int(v)
        return response

db = dinamopy.DinamoPy('dinamopy.json', MyHooks())

db.put(item={
    'customerId': 'xyz',
    'sk': 'CUST#xyz',
    'email': '[email protected]',
    'fullName': 'Rasim Andiran',
    'userPreferences': {'language': 'en', 'sort': 'date', 'sortDirection': 'ascending'}
})

db.overwrite(item={
    'customerId': 'xyz',
    'sk': 'CUST#xyz',
    'email': '[email protected]',
    'fullName': 'Rasim Andiran',
    'userPreferences': {'language': 'en', 'sort': 'date', 'sortDirection': 'ascending'}
})

db.get_customer_profile_by_customer_id(customerId='xyz')
db.get_bookmarks_by_customer_id(customerId='123')
db.get_customer_profile_by_email(email='[email protected]')
db.get_bookmarks_by_url(url='https://aws.amazon.com', customerId='123')
db.get_customer_folder(customerId='123', folder='Cloud')

db.update_customer_profile_by_customer_id(customerId='321', sk='CUST#321', new_fields={'email': '[email protected]'})
db.update_bookmarks_by_customer_id(customerId='123', sk='https://aws.amazon.com', new_fields={'folder': 'Tools'})
db.update_customer_profile_by_email(email='[email protected]', new_fields={'fullName': 'Rasim Andiran'})
db.update_bookmarks_by_url(url='https://aws.amazon.com', customerId='123', new_fields={'description': 'Deneme'})
db.update_customer_folder(customerId='123', folder='Cloud', new_fields={'folder': 'CloudFolder'})

db.delete_customer_profile_by_customer_id(customerId='123')
db.delete_bookmarks_by_customer_id(customerId='123', sk='https://aws.amazon.com', new_fields={'folder': 'Tools'})
db.delete_customer_profile_by_email(email='[email protected]', new_fields={'fullName': 'Rasim Andiran'})
db.delete_bookmarks_by_url(url='https://aws.amazon.com', customerId='123', new_fields={'description': 'Deneme'})
db.delete_customer_folder(customerId='123', folder='Cloud', new_fields={'folder': 'CloudFolder'})

dinamopy.json

{
    "region": "localhost",
    "port": 8000,
    "tableName": "CustomerBookmark",
    "partitionKey": "customerId", 
    "sortKey": "sk",
    "timestamps": true,
    "paranoid": true,
    "returnRawResponse": false,
    "logLevel": "debug",
    "accessPatterns": {
        "customerProfileByCustomerId": {
            "table": "table",
            "partitionKey": "customerId",
            "sortKey": "sk",
            "sortKeyOperator": "begins_with",
            "sortKeyValue": "CUST#"
        },
        "bookmarksByCustomerId": {
            "table": "table",
            "partitionKey": "customerId",
            "sortKey": "sk",
            "sortKeyOperator": "begins_with",
            "sortKeyValue": "http"
        },
        "customerProfileByEmail": {
            "table": "ByEmail",
            "partitionKey": "email"
        },
        "bookmarksByUrl": {
            "table": "ByUrl",
            "partitionKey": "url",
            "sortKey": "customerId"
        },
        "customerFolder": {
            "table": "ByCustomerFolder",
            "partitionKey": "customerId",
            "sortKey": "folder"
        }
    }
}

To-Do

  • More generic hooks
  • Logging
  • Tests
  • Documentation

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

You might also like...
A HugSQL-inspired database library for Python

PugSQL PugSQL is a simple Python interface for using parameterized SQL, in files. See pugsql.org for the documentation. To install: pip install pugsql

A library for python made by me,to make the use of MySQL easier and more pythonic

my_ezql A library for python made by me,to make the use of MySQL easier and more pythonic This library was made by Tony Hasson , a 25 year old student

Py2neo is a client library and toolkit for working with Neo4j from within Python

Py2neo Py2neo is a client library and toolkit for working with Neo4j from within Python applications. The library supports both Bolt and HTTP and prov

Databank is an easy-to-use Python library for making raw SQL queries in a multi-threaded environment.

Databank Databank is an easy-to-use Python library for making raw SQL queries in a multi-threaded environment. No ORM, no frills. Thread-safe. Only ra

aiopg is a library for accessing a PostgreSQL database from the asyncio

aiopg aiopg is a library for accessing a PostgreSQL database from the asyncio (PEP-3156/tulip) framework. It wraps asynchronous features of the Psycop

aiomysql is a library for accessing a MySQL database from the asyncio

aiomysql aiomysql is a "driver" for accessing a MySQL database from the asyncio (PEP-3156/tulip) framework. It depends on and reuses most parts of PyM

aioodbc - is a library for accessing a ODBC databases from the asyncio

aioodbc aioodbc is a Python 3.5+ module that makes it possible to access ODBC databases with asyncio. It relies on the awesome pyodbc library and pres

google-cloud-bigtable Apache-2google-cloud-bigtable (🥈31 · ⭐ 3.5K) - Google Cloud Bigtable API client library. Apache-2

Python Client for Google Cloud Bigtable Google Cloud Bigtable is Google's NoSQL Big Data database service. It's the same database that powers many cor

edaSQL is a library to link SQL to Exploratory Data Analysis and further more in the Data Engineering.
edaSQL is a library to link SQL to Exploratory Data Analysis and further more in the Data Engineering.

edaSQL is a python library to bridge the SQL with Exploratory Data Analysis where you can connect to the Database and insert the queries. The query results can be passed to the EDA tool which can give greater insights to the user.

Releases(latest)
GINO Is Not ORM - a Python asyncio ORM on SQLAlchemy core.

GINO - GINO Is Not ORM - is a lightweight asynchronous ORM built on top of SQLAlchemy core for Python asyncio. GINO 1.0 supports only PostgreSQL with

GINO Community 2.5k Dec 29, 2022
Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.

Redash is designed to enable anyone, regardless of the level of technical sophistication, to harness the power of data big and small. SQL users levera

Redash 22.4k Dec 30, 2022
Making it easy to query APIs via SQL

Shillelagh Shillelagh (ʃɪˈleɪlɪ) is an implementation of the Python DB API 2.0 based on SQLite (using the APSW library): from shillelagh.backends.apsw

Beto Dealmeida 207 Dec 30, 2022
Estoult - a Python toolkit for data mapping with an integrated query builder for SQL databases

Estoult Estoult is a Python toolkit for data mapping with an integrated query builder for SQL databases. It currently supports MySQL, PostgreSQL, and

halcyon[nouveau] 15 Dec 29, 2022
PostgreSQL database access simplified

Queries: PostgreSQL Simplified Queries is a BSD licensed opinionated wrapper of the psycopg2 library for interacting with PostgreSQL. The popular psyc

Gavin M. Roy 251 Oct 25, 2022
A Python DB-API and SQLAlchemy dialect to Google Spreasheets

Note: shillelagh is a drop-in replacement for gsheets-db-api, with many additional features. You should use it instead. If you're using SQLAlchemy all

Beto Dealmeida 185 Jan 01, 2023
Python ODBC bridge

pyodbc pyodbc is an open source Python module that makes accessing ODBC databases simple. It implements the DB API 2.0 specification but is packed wit

Michael Kleehammer 2.6k Dec 27, 2022
Tool for synchronizing clickhouse clusters

clicksync Tool for synchronizing clickhouse clusters works only with partitioned MergeTree tables can sync clusters with different node number uses in

Alexander Rumyantsev 1 Nov 30, 2021
Async ODM (Object Document Mapper) for MongoDB based on python type hints

ODMantic Documentation: https://art049.github.io/odmantic/ Asynchronous ODM(Object Document Mapper) for MongoDB based on standard python type hints. I

Arthur Pastel 732 Dec 31, 2022
A SQL linter and auto-formatter for Humans

The SQL Linter for Humans SQLFluff is a dialect-flexible and configurable SQL linter. Designed with ELT applications in mind, SQLFluff also works with

SQLFluff 5.5k Jan 08, 2023
Async database support for Python. 🗄

Databases Databases gives you simple asyncio support for a range of databases. It allows you to make queries using the powerful SQLAlchemy Core expres

Encode 3.2k Dec 30, 2022
Records is a very simple, but powerful, library for making raw SQL queries to most relational databases.

Records: SQL for Humans™ Records is a very simple, but powerful, library for making raw SQL queries to most relational databases. Just write SQL. No b

Kenneth Reitz 6.9k Jan 03, 2023
Application which allows you to make PostgreSQL databases with Python

Automate PostgreSQL Databases with Python Application which allows you to make PostgreSQL databases with Python I used the psycopg2 library which is u

Marc-Alistair Coffi 0 Dec 31, 2021
A wrapper around asyncpg for use with sqlalchemy

asyncpgsa A python library wrapper around asyncpg for use with sqlalchemy Backwards incompatibility notice Since this library is still in pre 1.0 worl

Canopy 404 Dec 03, 2022
Dlsite-doujin-renamer - Dlsite doujin renamer tool with python

dlsite-doujin-renamer Features 支持深度查找带有 RJ 号的文件夹 支持手动选择文件夹或拖拽文件夹到软件窗口 支持在 config

111 Jan 02, 2023
python-beryl, a Python driver for BerylDB.

python-beryl, a Python driver for BerylDB.

BerylDB 3 Nov 24, 2021
Use SQL query in a jupyter notebook!

SQL-query Use SQL query in a jupyter notebook! The table I used can be found on UN Data. Or you can just click the link and download the file undata_s

Chuqin 2 Oct 05, 2022
A collection of awesome sqlite tools, scripts, books, etc

Awesome Series @ Planet Open Data World (Countries, Cities, Codes, ...) • Football (Clubs, Players, Stadiums, ...) • SQLite (Tools, Books, Schemas, ..

Planet Open Data 205 Dec 16, 2022
Lazydata: Scalable data dependencies for Python projects

lazydata: scalable data dependencies lazydata is a minimalist library for including data dependencies into Python projects. Problem: Keeping all data

629 Nov 21, 2022
Familiar asyncio ORM for python, built with relations in mind

Tortoise ORM Introduction Tortoise ORM is an easy-to-use asyncio ORM (Object Relational Mapper) inspired by Django. Tortoise ORM was build with relati

Tortoise 3.3k Dec 31, 2022