DEV Community

Cover image for Onstro-DB a fast DB
Adwaith Rajesh
Adwaith Rajesh

Posted on

2 2

Onstro-DB a fast DB

Installation

pip install onstro-db
Enter fullscreen mode Exit fullscreen mode

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 OnstroDb
import time

test_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 insert
data = []
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 DB
start = time.time()
db.add(data)
stop = time.time()

print("Elapsed Time: ", stop - start)

Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay