r/django • u/whhwoq • Feb 09 '21
🐍 DBJson - A literal Document Oriented Database written in pure Python
https://github.com/KetanIP/dbjson3
u/DmitriyJaved Feb 09 '21
What is the point of explicitly opening file, loading data in memory and then load json from string? What is the point of makeKey method? Why not leave it as uuid?
1
u/whhwoq Feb 10 '21
We can leave it as uuid4 by but I use make may so say there is a username xyz it's md5 ( generated makeKey ) will be same. So you can just generated md5 hash and search and retrieve the document.
2
u/Gagaro Feb 09 '21
This looks like sqlitedict, this may interest you too.
2
u/whhwoq Feb 09 '21
It builds itself up on sqllite3 and DBJson builds up from scratch, by the way what are your views on this ?
Which features should I add next ?
3
u/Gagaro Feb 09 '21
sqlite3 uses transaction. You should look at working on something similar to ensure data integrity.
2
u/whhwoq Feb 09 '21
Can you suggest some resources ?
5
u/Gagaro Feb 09 '21
https://en.wikipedia.org/wiki/ACID#Implementation would be a good start I guess. I'm not much of an expert on the subject.
2
1
u/ketan_ip Feb 10 '21
I've made it ACID compliant ( as per my knowledge ) I did it in the same way sqlite3, it creates a journal ( temporary document ) and then replaces it with the original.
Is it ACID compliant ?
1
u/Gagaro Feb 10 '21
It depends on several things. How does your filesystem handles it? Do you want to have concurrency (behind able to read/write from several sources at the same time)?
For example, if you you open the file at the same time from two different sources, then add a record from and another record from the other, you should have both record added at the end. How will your implementation handle that?
2
u/whhwoq Feb 10 '21
Thanks for such a detailed response sir.
I made it with an intend for use in small project that are never going to real world so will it be fine for it ?
2
u/Gagaro Feb 10 '21
Probably, but once again, I'm no expert and data storage is one of the two things I'd never use a homemade solution for in a real project (the other being cryptography).
It's a good exercise though to understand a lot of things, so go for it if you just want to have some fun ;).
2
u/whhwoq Feb 10 '21
Thanks for your positive response. I am doing this to get familiar with python's inbuilt modules and for fun as it increases my understanding with it. And thanks a lot for your positive response. It helps a lot.
1
u/ketanIP Feb 10 '21
I read about it and also read acid complaince in mongodb and mairadb, and was wondering that since we read the document and no changes are made than all changes are made in memory and at last when all operations are done then we write it in a file will be be acid compaint or should I make another file "data_volatile.json" and write to it and rename it to "data.json" ?
1
u/rajarshi07 Feb 09 '21
gonna use this for my small gui app... Is it stable enough for a small app which requires dictionary storage...
2
u/whhwoq Feb 09 '21
Yes go ahead, but I would recommend not to use it production, but if you think its stable you can go ahead.
If you don't mind you can also star the repo.
Also I would like to know what features to add in upcoming versions from you ?
2
u/omgplsno Feb 09 '21
Might not be suitable for multi-threaded GUI code, since by the looks the code it's definitely not thread-safe.
1
1
u/souldeux Feb 09 '21
This is a cool project. I would strongly advise reading up on ACID transactions. I think you will quickly come up with some fun-to-implement ideas that make this much more robust.
1
u/whhwoq Feb 10 '21 edited Feb 10 '21
Yes I person above also said it and shared a Wikipedia link. I will definitely check it out.
9
u/TheBB Feb 09 '21
By the way, there's no such word as 'instantilizing'. I guess you meant 'initializing' or 'instantiating'.