Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
July 19, 2021 09:37 am GMT

Onstro-DB a fast DB

Installation

pip install onstro-db

Let's see how fast it is.

In this example, we can make a DB with 4 columns and in which 2 columns have a default value. Which are added during Runtime.
We will be adding 10,000 values to the DB and check how fast it is.

The test code

from onstrodb import OnstroDbimport timetest_schema = {    "name": {"type": "str", "required": True},    "age": {"type": "int", "required": True},    "place": {"type": "str", "default": "canada"},    "alive": {"type": "bool", "default": True}}db = OnstroDb(db_name="test", in_memory=True, schema=test_schema)# generate the data to insertdata = []for i in range(10_000):    print(i, end="\r", flush=True)    d = {"name": f"ad{i}", "age": i}    data.append(d)# insert the data into the DBstart = time.time()db.add(data)stop = time.time()print("Elapsed Time: ", stop - start)

Here we first create all the data we want to insert and we time the insertion process.

Here are the results.

Elapsed Time:  1.077016830444336

Onstro-Db supports full CRUD operation, comes with a simple CLI, has a strict schema, and also prevents data duplication by default.

As you can see this thing is fast. To know more visit the Github repo here.

Star and follow the repo for future updates.


Original Link: https://dev.to/adwaithrajesh/onstro-db-a-fast-db-5bn8

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To