Need help with tinydb?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

4.6K Stars 414 Forks MIT License 633 Commits 15 Opened issues


TinyDB is a lightweight document oriented database optimized for your happiness :)

Services available


Need anything else?

Contributors list

.. image:: :scale: 100% :height: 150px

|Build Status| |Coverage| |Version|

Quick Links

  • Example Code
  • Supported Python Versions
  • Documentation 
  • Changelog 
  • Extensions 
  • Contributing


TinyDB is a lightweight document oriented database optimized for your happiness :) It's written in pure Python and has no external dependencies. The target are small apps that would be blown away by a SQL-DB or an external database server.

TinyDB is:

  • tiny: The current source code has 1800 lines of code (with about 40% documentation) and 1600 lines tests.

  • document oriented: Like MongoDB_, you can store any document (represented as

    ) in TinyDB.
  • optimized for your happiness: TinyDB is designed to be simple and fun to use by providing a simple and clean API.

  • written in pure Python: TinyDB neither needs an external server (as e.g.

    _) nor any dependencies from PyPI.
  • works on Python 3.6+ and PyPy3: TinyDB works on all modern versions of Python and PyPy.

  • powerfully extensible: You can easily extend TinyDB by writing new storages or modify the behaviour of storages with Middlewares.

  • 100% test coverage: No explanation needed.

To dive straight into all the details, head over to the

TinyDB docs
. You can also discuss everything related to TinyDB like general development, extensions or showcase your TinyDB-based projects on the
discussion forum 

Supported Python Versions

TinyDB has been tested with Python 3.6 - 3.9 and PyPy3.

Example Code

.. code-block:: python

>>> from tinydb import TinyDB, Query
>>> db = TinyDB('/path/to/db.json')
>>> db.insert({'int': 1, 'char': 'a'})
>>> db.insert({'int': 1, 'char': 'b'})

Query Language

.. code-block:: python

>>> User = Query()
>>> # Search for a field value
>>> == 'John')
[{'name': 'John', 'age': 22}, {'name': 'John', 'age': 37}]

>>> # Combine two queries with logical and >>> == 'John') & (User.age <= 30)) [{'name': 'John', 'age': 22}]

>>> # Combine two queries with logical or >>> == 'John') | ( == 'Bob')) [{'name': 'John', 'age': 22}, {'name': 'John', 'age': 37}, {'name': 'Bob', 'age': 42}]

>>> # More possible comparisons: != < > <= >= >>> # More possible checks: where(...).matches(regex), where(...).test(your_test_func)


.. code-block:: python

>>> table = db.table('name')
>>> table.insert({'value': True})
>>> table.all()
[{'value': True}]

Using Middlewares

.. code-block:: python

>>> from tinydb.storages import JSONStorage
>>> from tinydb.middlewares import CachingMiddleware
>>> db = TinyDB('/path/to/db.json', storage=CachingMiddleware(JSONStorage))


Whether reporting bugs, discussing improvements and new ideas or writing extensions: Contributions to TinyDB are welcome! Here's how to get started:

  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug
  2. Fork
    the repository 
    _ on Github, create a new branch off the
    branch and start making your changes (known as
    GitHub Flow 
  3. Write a test which shows that the bug was fixed or that the feature works as expected
  4. Send a pull request and bug the maintainer until it gets merged and published ☺

.. |Build Status| image:: :target: .. |Coverage| image:: :target: .. |Version| image:: :target: .. _Buzhug: .. _CodernityDB: .. _MongoDB:

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.