Codernitydb Introduction and usages of NoSQL database developed by pure Python _python

Source: Internet
Author: User
Tags import database

Look at this logo, some like Python snakes. This presentation of the database Codernitydb was developed in pure python.

Previously used the next tinydb this local database, but also in an API service in the next, at first feel the speed of some do not give force, the result of a see the way to achieve, is really too bird, incredibly is the memory of JSON, even a binary compression is not. The codernitydb described 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 the option to support the HTTP service version (Codernitydb-http), and the Python client library (codernitydb-pyclient), which targets a 100%-compliant, embedded version.

Main Features

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

Codernitydb Database Operation code instance:

Copy Code code 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.