-
Notifications
You must be signed in to change notification settings - Fork 23
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
innopreneur
wants to merge
6
commits into
bigchaindb:master
Choose a base branch
from
innopreneur:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
af49ed3
initial BEP for orm implementation for python driver
innopreneur 2401bbd
minor image renaming
innopreneur 993ceca
minor image renamin
innopreneur f6a47f1
updated BEP as per reviews
innopreneur aeec991
updated BEP as per reviews
innopreneur f6a7038
updates comments and code blocks with python doc strings
innopreneur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
``` | ||
shortname: 11/PYTHON-ORM-DRIVER | ||
name: ORM Implementation For Official BigchainDB Python Driver | ||
type: Standard | ||
status: raw | ||
editor: Manan Patel <[email protected]> | ||
``` | ||
|
||
# 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 implmentation is inspired from the ORM implementation of [bigchaindb javascript driver](https://github.com/bigchaindb/js-driver-orm).This ORM SHOULD be implemented on top of python driver - [https://github.com/bigchaindb/bigchaindb-driver](https://github.com/bigchaindb/bigchaindb-driver). | ||
This implementation SHOULD include following **CRAB** operations - | ||
|
||
1. **C**reate - performs CREATE transaction with asset payload into bigchainDB. | ||
|
||
```python | ||
def create(inputs): | ||
""" | ||
creates the asset in bigchaindb | ||
@param {dict} inputs - dictionary containing keypairs and data for the asset | ||
""" | ||
``` | ||
2. **R**etrieve - queries or fetches asset from bigchainDB. | ||
|
||
```python | ||
def retrieve(input): | ||
""" | ||
retrieves the asset for a given input query | ||
@param {dict} input - query to retrieve asset | ||
""" | ||
``` | ||
|
||
3. **A**ppend - performs TRANSFER transaction with asset payload to a given public address in bigchainDB. | ||
|
||
```python | ||
def append(inputs): | ||
""" | ||
appends (i.e. transfer transaction) the asset in bigchaindb | ||
@param {dict} inputs - dictionary incl. public key of new owner and private key for current owner | ||
""" | ||
``` | ||
4. **B**urn - performs TRANSFER transaction with asset payload to a vanity address (in our case *BurnBurnBurnBurnBurnBurnBurnBurnBurnBurnBurn* - 11 times Burn) | ||
|
||
```python | ||
def burn(inputs): | ||
""" | ||
burns the asset to unretrievable address | ||
@param {dict} inputs - dictionary containing details of burn address (i.e. public key) | ||
""" | ||
``` | ||
|
||
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._ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please replace the current copyright waiver text with the following block of HTML. (HTML is valid Markdown.) <p xmlns:dct="http://purl.org/dc/terms/">
<a rel="license"
href="http://creativecommons.org/publicdomain/zero/1.0/">
<img src="http://i.creativecommons.org/p/zero/1.0/88x31.png" style="border-style: none;" alt="CC0" />
</a>
<br />
To the extent possible under law, all contributors to this BEP
have waived all copyright and related or neighboring rights to this BEP.
</p> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change the shortname of this BEP to BEP-11 then we can close issue #32 because all other shortnames have been updated to the BEP-N format.