Skip to main content

A tiny NoSQL database with in-memory caching

Project description


Tinyble is a super lightweight database inheriting TinyDB. It is a document-oriented NoSQL but can also be used as a SQL database. It is most suitable for small applications where MongoDB is too way overkill. The features are:

  • Written in pure Python and works well with most Python versions
  • Very small, stored in JSON format and requires no external server
  • Different from TinyDB, flexible auto-paging is provided to enable fast write-in and read-out
  • Combine in-memory caching with disk storage to trade-off speed and reliability

Difference from TinyDB

TinyDB stores each table in a single JSON file. For every IO operation, the JSON file will be wholly read and rewritten. As the file size gets larger or when there are many write-in operations, the speed can be dramatically slow.

Tinyble uses a separate thread to manage all the write/update operations. Specifically, all newly-updated data will first be stored in memory and an internal timer expires, they will be batch-written in the JSON file.

This reduces the number of IO operations. Moreover, a limit on the JSON file size is imposed when the size exceeds the limit, a new JSON file is created. This limits the volume of each read operation.

The internal timer and the file size can be set by users.


The latest version is v0.1.4. The current version is still on experimental status. Please use it with caution. Please contact me if you find any bugs/problems.


  • added the close() function
  • added the projection (partial search) function
  • added the rst file


  • fixed the print bug
  • fixed the ‘get’ method bug

How to install

The easiest way to install is to use

(sudo) pip install tinyble

in the command line tool.

Working with Django

A very simple and ugly example showing the use of Tinyble with Django can be found in Tinyble with Django


Create a new database and a new collection

db = Tinyble('data')
collection = db.collection('example')

Insert some data

col = db.collection('example')

col.insert({'type': 'apple', 'number': 1})
col.insert({'type': 'pineapple', 'number': 2})
col.insert({'type': 'blueberry', 'number': 3})

Update some data

col.update({'number':10}, cond= where('type')=='pineapple')

Delete some data


Other usages are very similar to TinyDB.

Set the parameters

col.setting(file_size=100, query_cache_size=10, write_freq=5)

The above setting means each JSON file is limited to 100 entries and the database will store the latest 10 query results in memory and write-to-disk frequency is 5s.

Select some data'number')>2)

Select part of data in a document'type')!= 'pineapple', ['number'])

This will only show the ‘number’ key, not the whole dictionary.

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
tinyble- (10.9 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page