Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BEP for ORM implementation of Python driver (BEP-11) #57

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions 21/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
```
shortname: 21/PYTHON-ORM-DRIVER
name: Orm implementation for official bigchaindb python driver
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write the name in title case: ORM Implementation for Official BigchainDB Python Driver

type: Standard
status: raw
editor: Manan Patel <manan@bigchaindb.com>
```

# Abstract

This is a proposal to implement ORM based wrapper for official bigchaindb [python driver](https://github.com/bigchaindb/bigchaindb-driver). Official driver provides bare bones pyhton API on top of HTTP API to connect to BigchainDB network, but ORM implementation's aim is to provide a CRAB based operational model on top of official python API in order to simplify operations on bigchainDB network - thereby improving community adoption and engagement.

## Language

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [BCP 14](https://tools.ietf.org/html/bcp14) \[[RFC2119](https://tools.ietf.org/html/rfc2119)\] \[[RFC8174](https://tools.ietf.org/html/rfc8174)\] when, and only when, they appear in all capitals, as shown here.

# Motivation

The need for this implementation is driven by following rationale -

* To provide simpler API to interact and perform operations on bigchainDB. Since, traditionally ORM based CRUD (Create, Read, Update, Delete) are the most used basic operations for the database (SQL and NoSQL), CRAB model for blockchains (bigchainDB in this case) reduces the learning curve for non-blockchain developers and improves community engagement. This is specifically true for python developers as Django (one of the most popular python framework) incorporates ORM model to perform CRUD operations.
* Our [ORM implementation](https://github.com/bigchaindb/js-driver-orm) of [javascript driver](https://github.com/bigchaindb/js-bigchaindb-driver) has recently shown good traction and usage within community.
* We would like to keep consistency with implementations related to both - javascript and python, offical drivers.

# Specification

This Orm should be implemented on top of python driver - [https://github.com/bigchaindb/bigchaindb-driver](https://github.com/bigchaindb/bigchaindb-driver).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write ORM in all caps, here and elsewhere. It's an acronym.

This implementation SHOULD include following **CRAB** operations -

1. **C**reate - performs CREATE transaction with asset payload into bigchainDB.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a specification for a Python ORM, it should include specific names and signatures (argument lists) for the functions, classes, methods or whatever must be implemented. The names and signatures could be inspired by the ones used in the JavaScript ORM, but of course names should be "Pythonic."

https://www.python.org/dev/peps/pep-0008/#naming-conventions

2. **R**etrieve - queries or fetches asset from bigchainDB.
3. **A**ppend - performs TRANSFER transaction with asset payload to a given public address in bigchainDB.
4. **B**urn - performs TRANSFER transaction with asset payload to a vanity address (in our case *BurnBurnBurnBurnBurnBurnBurnBurnBurnBurnBurn* - 11 times Burn)

This implementation SHOULD also include tests and code coverage of atleast 95%.


# Architecture


## Current Architecture

![Image of Current Python driver implementation](./images/before-orm-implementation.png)

## Architecture After ORM Implementation

![Image of ORM Python driver implementation](./images/after-orm-implementation.png)

# References

* [CRUD vs CRAB](https://blog.bigchaindb.com/crab-create-retrieve-append-burn-b9f6d111f460)
* [BigchainDB's official python driver](https://github.com/bigchaindb/bigchaindb-driver)
* [BigchainDB's official python driver documentation](https://docs.bigchaindb.com/projects/py-driver/en/latest/index.html)
* [BigchainDB's official javascript driver](https://github.com/bigchaindb/js-bigchaindb-driver)
* [ORM implementation of javascript driver](https://github.com/bigchaindb/js-driver-orm)
* [CRAB tutorial showing javascript ORM driver usage](https://github.com/bigchaindb/tutorial-crab)

# Copyright Waiver

_To the extent possible under law, the person who associated CC0 with this work has waived all copyright and related or neighboring rights to this work._
Binary file added 21/images/after-orm-implementation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 21/images/before-orm-implementation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.