Skip to main content

A lightweight in-memory database for Python — perfect for testing and prototyping.

Project description

MockDB

MockDB is a lightweight, in-memory Python database for testing, prototyping, and mocking database operations without installing any external database servers.

It mimics the basic behavior of real databases like MongoDB or SQLite but runs entirely in memory. Ideal for developers who want fast CRUD operations without setup overhead.

Features

  • In-memory storage (no installation required)
  • Table creation and management
  • CRUD operations: insert, find, update, delete
  • Save and load database to JSON
  • Lightweight and zero-dependency
  • Perfect for unit testing, demos, and small projects

Installation

pip install mockdb

Functions

> insert(data: dict)
> find(query: dict)
> update(query: dict, new_data: dict)
> delete(query: dict)
> to_json()
> create_table(name: str)
> get_table(name: str)
> drop_table(name: str)
> save_to_file(filepath: str)
> load_from_file(filepath: str)

Example Usage

    from mockdb import Database

    # Create a database
    db = Database()

    # Create a table
    users = db.create_table("users")

    # Insert records
    users.insert({"name": "Vibhakar", "age": 17})
    users.insert({"name": "Shiju", "age": 16})

    # Query records
    print(users.find({"age": 17}))

    # Update records
    users.update({"name": "Shiju"}, {"age": 17})

    # Delete records
    users.delete({"name": "Vibhakar"})

    # Save/load
    db.save_to_file("mockdb.json")
    db.load_from_file("mockdb.json")

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

dummydb-0.1.3.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

dummydb-0.1.3-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file dummydb-0.1.3.tar.gz.

File metadata

  • Download URL: dummydb-0.1.3.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for dummydb-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e41cc1f842fb7277ef35c1dc41bb44e0420e1eec3a53471c5cfb6d8b8fc69439
MD5 0f61b861b07ddf8b9ade3ca5e1fb4d90
BLAKE2b-256 bc1fe63aa2bef22abe60d40c0c1ee328f980af9670df9cc62f59ab84289df04e

See more details on using hashes here.

File details

Details for the file dummydb-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: dummydb-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for dummydb-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cb0fa9e1b7bec9b45cd7928d0ae91a3ace49345b387a5cf6ea5dbf98b4ed6939
MD5 b5a3893b5bd2138911cfb30221f07e49
BLAKE2b-256 535114bf6da134e05e94a9b4340ef67f1b74cf10d9a92a108e35e710cc542b02

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