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)
Generate database table diagram from SQL data definition.

sql2diagram Generate database table diagram from SQL data definition. e.g. "CREATE TABLE ..." See Example below How does it works? Analyze the SQL to

django-cas-ng 1 Feb 08, 2022
Py2neo is a comprehensive toolkit for working with Neo4j from within Python applications or from the command line.

Py2neo Py2neo is a client library and toolkit for working with Neo4j from within Python applications and from the command line. The library supports b

Nigel Small 1.2k Jan 02, 2023
MySQL database connector for Python (with Python 3 support)

mysqlclient This project is a fork of MySQLdb1. This project adds Python 3 support and fixed many bugs. PyPI: https://pypi.org/project/mysqlclient/ Gi

PyMySQL 2.2k Dec 25, 2022
SQL queries to collections

SQC SQL Queries to Collections Examples from sqc import sqc data = [ {"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 3, "b": 2}, ] Simple filte

Alexander Volkovsky 0 Jul 06, 2022
Find graph motifs using intuitive notation

d o t m o t i f Find graph motifs using intuitive notation DotMotif is a library that identifies subgraphs or motifs in a large graph. It looks like t

APL BRAIN 45 Jan 02, 2023
Python PostgreSQL adapter to stream results of multi-statement queries without a server-side cursor

streampq Stream results of multi-statement PostgreSQL queries from Python without server-side cursors. Has benefits over some other Python PostgreSQL

Department for International Trade 6 Oct 31, 2022
Baserow is an open source no-code database tool and Airtable alternative

Baserow is an open source no-code database tool and Airtable alternative

1.3k Jan 01, 2023
Implementing basic MongoDB CRUD (Create, Read, Update, Delete) queries, using Python.

MongoDB with Python Implementing basic MongoDB CRUD (Create, Read, Update, Delete) queries, using Python. We can connect to a MongoDB database hosted

MousamSingh 4 Dec 01, 2021
Implementing basic MySQL CRUD (Create, Read, Update, Delete) queries, using Python.

MySQL with Python Implementing basic MySQL CRUD (Create, Read, Update, Delete) queries, using Python. We can connect to a MySQL database hosted locall

MousamSingh 5 Dec 01, 2021
A fast MySQL driver written in pure C/C++ for Python. Compatible with gevent through monkey patching.

:: Description :: A fast MySQL driver written in pure C/C++ for Python. Compatible with gevent through monkey patching :: Requirements :: Requires P

ESN Social Software 549 Nov 18, 2022
Amazon S3 Transfer Manager for Python

s3transfer - An Amazon S3 Transfer Manager for Python S3transfer is a Python library for managing Amazon S3 transfers. Note This project is not curren

the boto project 158 Jan 07, 2023
DBMS Mini-project: Recruitment Management System

# Hire-ME DBMS Mini-project: Recruitment Management System. 💫 ✨ Features Python + MYSQL using mysql.connector library Recruiter and Client Panel Beau

Karan Gandhi 35 Dec 23, 2022
Python version of the TerminusDB client - for TerminusDB API and WOQLpy

TerminusDB Client Python Development status ⚙️ Python Package status 📦 Python version of the TerminusDB client - for TerminusDB API and WOQLpy Requir

TerminusDB 66 Dec 02, 2022
A wrapper for SQLite and MySQL, Most of the queries wrapped into commands for ease.

Before you proceed, make sure you know Some real SQL, before looking at the code, otherwise you probably won't understand anything. Installation pip i

Refined 4 Jul 30, 2022
Toolkit for storing files and attachments in web applications

DEPOT - File Storage Made Easy DEPOT is a framework for easily storing and serving files in web applications on Python2.6+ and Python3.2+. DEPOT suppo

Alessandro Molina 139 Dec 25, 2022
TileDB-Py is a Python interface to the TileDB Storage Engine.

TileDB-Py TileDB-Py is a Python interface to the TileDB Storage Engine. Quick Links Installation Build Instructions TileDB Documentation Python API re

TileDB, Inc. 149 Nov 28, 2022
SpyQL - SQL with Python in the middle

SpyQL SQL with Python in the middle Concept SpyQL is a query language that combines: the simplicity and structure of SQL with the power and readabilit

Daniel Moura 853 Dec 30, 2022
Sample scripts to show extracting details directly from the AIQUM database

Sample scripts to show extracting details directly from the AIQUM database

1 Nov 19, 2021
MySQL Operator for Kubernetes

MySQL Operator for Kubernetes The MYSQL Operator for Kubernetes is an Operator for Kubernetes managing MySQL InnoDB Cluster setups inside a Kubernetes

MySQL 462 Dec 24, 2022
A tutorial designed to introduce you to SQlite 3 database using python

SQLite3-python-tutorial A tutorial designed to introduce you to SQlite 3 database using python What is SQLite? SQLite is an in-process library that im

0 Dec 28, 2021