Codernitydb Introduction and usage examples of NoSQL database developed by Pure Python

Source: Internet
Author: User
Tags import database
Look at this logo, some python-like snakes. The database Codernitydb introduced this time is purely python-developed.

The previous use of the next tinydb this local database, also in an API service used, at first felt that the speed of some not to force, the result of a look at the implementation of the way, is really too bird, incredibly is the storage of JSON, even a binary compression is not. The Codernitydb introduced here is also a small database of pure development.

Codernitydb is an open source, pure Python language (no third party dependent), fast, multi-platform NoSQL database. It has options to support the HTTP service version (Codernitydb-http), and the Python client library (codernitydb-pyclient), which targets the 100% compatible embedded version.

Key Features

1.Pyhon Native Support
2. Multiple indexes
3. Fast (up to 50 000 insert operations per second)
4. Embedded mode (default) and server mode (codernitydb-http), plus client library (codernitydb-pyclient), capable of 100% compatible
5. Easy to complete customer storage

Codernitydb Database Operation code Example:

The code is as follows:


Insert (Simple)

From codernitydb.database Import Database

db = Database ('/tmp/tut1 ')
Db.create ()

Insertdict = {' X ': 1}
Print Db.insert (insertdict)


 

Insert

From codernitydb.database Import Database
From Codernitydb.hash_index import Hashindex

Class Withxindex (Hashindex):
def __init__ (self, *args, **kwargs):
kwargs[' key_format ' = ' I '
Super (Withxindex, self). __init__ (*args, **kwargs)

def make_key_value (self, data):
A_val = Data.get ("x")
If A_val is not None:
Return A_val, None
Return None

def make_key (self, key):
Return key

db = Database ('/tmp/tut2 ')
Db.create ()

X_ind = Withxindex (Db.path, ' x ')
Db.add_index (X_ind)

Print Db.insert ({' X ': 1})
 
 

Count

From codernitydb.database Import Database

db = Database ('/tmp/tut1 ')
Db.open ()

Print Db.count (Db.all, ' x ')
 

Get

From codernitydb.database Import Database

db = Database ('/tmp/tut2 ')
Db.open ()

Print db.get (' x ', 1, with_doc=true)
 

Delete

From codernitydb.database Import Database

db = Database ('/tmp/tut2 ')
Db.open ()

Curr = Db.get (' x ', 1, with_doc=true)
doc = curr[' Doc ')

Db.delete (DOC)
 
 

Update

From codernitydb.database Import Database

db = Database ('/tmp/tut2 ')
Db.create ()

Curr = Db.get (' x ', 1, with_doc=true)
doc = curr[' Doc ')

doc[' Updated ') = True
Db.update (DOC)

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.