dummy database written in python
Go to file
2019-08-23 02:53:14 +02:00
.gitignore Add index file and make base class composite with two BaseFile variables 2019-08-22 00:33:59 +02:00
dummy_crud_database.py cleanup 2019-08-23 02:53:14 +02:00
LICENSE Add index file and make base class composite with two BaseFile variables 2019-08-22 00:33:59 +02:00
process_size.py Move test data generation outside perf test and remove multiple os size calls 2019-08-23 02:42:52 +02:00
README.md Update README.md 2019-08-23 02:50:59 +02:00

dummy crud database

Description

I always wanted to make simple database so I made one only for educational purposes inspired by this javaworld article

It can store any binary data. Implemented in python in under 250 lines of code.
Probably can be shorter but it's just a gig.

Supports

  • insert data
  • update data
  • delete data
  • read data by index
  • read all data

For simplicity data and index files is append only.
Index file is loaded and stored as dictionary in memory at start.

Dependencies

Optional psutil to display pid statistics after running perf test.

Run

I tested it using python3.7

Test run by default:

  • removes 2 files test.db, test.index if those files exists
  • create 2 files test.db, test.index
  • write and index 1 million random string between (100, 1000) characters to test.db file
  • read 1 million random elements from file
  • remove object
  • update object
  • read one object
python dummy_crud_database.py 

Output

Test elements size 1000000
write elements in 35.61809206008911s - 28075.61950013945 per second
read elements in 13.677339792251587s - 73113.63285472477 per second
size :  1000000
database fsize :  539.06 MB
index fsize :  7.63 MB

So it looks like it can do 28k inserts per second and around 73k reads per second on my computer (write time including random choice from 1k elements array).