Skip to main content

High performance JSON-oriented database

Project description

SimpleBase is a lightweight JSON based serverless database with improved performance on key operations

The strength of document-oriented NoSQL database is their natural simplicity, but they are usually not very fast (unless they are serious server databases like MongoDB). SimpleBase solves performance issues in critical areas

  • Instant addition of new records to collections, regardless of the size of the collection due to a special storage architecture

  • Faster work with operations, due to the fact that it is not required to encode / decode the entire collection (which can be very large)

  • Collections are always stored in RAM with concurrency change tracking: data is re-read from disk only if it has been changed by another process

  • ACID for multi-user and multi-threading

  • Two types of indexes for key types of queries - a hash index and a special B-tree for full-text search

  • Support for transactions (sessions)

  • MongoDB-like syntax, incl. 100% similar query language

  • Written in pure python, only about 1800 lines

Why SimpleBase?

It was written for situations where you need to organize a local database without a server with a JSON-oriented interface. But at the same time, increased performance requirements: for large collections (1000000+ documents in the collection), fast, almost instantaneous execution of some operations is required:

  • Add a new document to the collection with 1000000 documents - 0.007 seconds, with 2000000 documents - also 0.0007 seconds - ie. operation time does not depend on the size of the table

  • Find an element by equality in a collection with 1000000+ entries in 1-2 microseconds

  • Organize real-time search by occurrence of a string across a large collection without friezes

from pysimplebase import SimpleBase,DBSession

#creatig database
db = SimpleBase("samples_db")

#inserting documents into collection
id = db['goods'].insert({"name":"coffee", "price":15}) #insert one document
print(db['goods'].get(id))

inserted = db['goods'].insert([{"name":"apple", "price":2},{"name":"apple", "price":3}]) #insert dataset

#insert or update (upsert)
db['goods'].insert({"name":"coffee", "price":16,"_id":id},upsert=True)
print(db['goods'].get(id))

#transaction
with DBSession(db) as s:
    inserted = db['income'].insert({"product_id":id} , session=s)
    inserted = db['outgoing'].insert({"product_id":id} , session=s)

#updating
db['goods'].update(inserted,{"updated":True})
print(db['goods'].all())

#simple search without index
result = db['goods'].find({"name":"apple"})

#building complex queries
result = db['goods'].find({"$and":[
    {"price":{"$gt":1}},
    {"price":{"$lte":10}}
    ]}
    )
print(result)

#hash indexes for unique values
db['goods'].register_hash_index("hash_dynamic","name", dynamic=True) #there are dynamic and stored indexes
db['goods'].reindex_hash("hash_dynamic")
r = db['goods'].get_by_index(db["hash_dynamic"],"apple")


#text indexes
db['goods'].register_text_index("fts","name", dynamic=True) #there are dynamic and stored indexes
db['goods'].reindex_text("fts")
r = db['goods'].search_text_index("appl")

#delete
db['goods'].delete(id)
db['goods'].delete(inserted)

#clear
db['goods'].clear()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysimplebase-0.0.8.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysimplebase-0.0.8-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file pysimplebase-0.0.8.tar.gz.

File metadata

  • Download URL: pysimplebase-0.0.8.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for pysimplebase-0.0.8.tar.gz
Algorithm Hash digest
SHA256 9e3bc3db424b8b4ac86c3167b3dde27be924bc86017b8fe83ceedb9833ad1144
MD5 b8a61ab71b43aa785a265aa814f28d38
BLAKE2b-256 597b81ddb78fd7ec90132026ad21c886d8509236b83af4b1c78ad40031b4ab16

See more details on using hashes here.

File details

Details for the file pysimplebase-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: pysimplebase-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for pysimplebase-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 3cd37019b6e9a9a44811b11628768cea6fb810358498400a5494e946cb549fbc
MD5 0a32c947fd8c9daf88930029ed608575
BLAKE2b-256 56190e3a30de4b823f2f6b704897b187e23a691083bb5f625b1809b787679808

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page