TinyDB in Python - Simple Database For Personal Projects
Вставка
- Опубліковано 21 лип 2024
- In this Python Tutorial, I want to show you how to work with TinyDB. TinyDB is a tiny, document oriented database which is perfect for small personal projects. The API is super simple and fun to use. I show you basic functionalities like adding, deleting, updating, and searching. TinyDB is open sourced an can be found on GitHub:
github.com/msiemens/tinydb
Update 07/2020:
Unfortunately some of the used methods have been removed in the newest 4.0 version:
tinydb.readthedocs.io/en/stab...
~~~~~~~~~~~~~~ GREAT PLUGINS FOR YOUR CODE EDITOR ~~~~~~~~~~~~~~
✅ Write cleaner code with Sourcery: sourcery.ai/?... *
📚 Get my FREE NumPy Handbook:
www.python-engineer.com/numpy...
📓 Notebooks available on Patreon:
/ patrickloeber
⭐ Join Our Discord : / discord
If you like this Tutorial, please subscribe to the channel!
The code can be found here:
github.com/patrickloeber/pyth...
Further readings:
tinydb.readthedocs.io/en/latest/
You can find me here:
Website: www.python-engineer.com
Twitter: / patloeber
GitHub: github.com/patrickloeber
Icon: fontawesome.com/icons/database
#Python #database
----------------------------------------------------------------------------------------------------------
* This is a sponsored link. By clicking on it you will not have any additional costs, instead you will support me and my project. Thank you so much for the support! 🙏
This is a great video and thank you for posting it. There are really no other up to date guides on UA-cam besides the MIT App implementations.
Glad you like it :)
This is very good. Solid stuff. The purge() > truncate() thing is not a problem at all. Thanks Patrick.
thanks!
how can i do the same but in a website, i mean like an online database to u can insert in a website table the user data?
how does one access these key values however? when you have {name: 'Max'}, how are you able to access Max
Excellent explanation, thank you!
thanks!
How do you get the age number insted of getting everything?
hey nice tutorial but i have a problem.
If i copy your code i get an bad file descriptor error in line 5 "db.insert({'type': 'peach', 'count': 3})".
Do you know what could be wrong?
oh man this video just saved me from a huge headache, thanks
glad to hear this :)
@@patloeber Btw, since you replied so quickly. I have to say that, for calling a specific key of the database, for me it didn't work like User.name, but It did work like User["name"], so in one case its treating it as an attribute and in the other as a key (I think?). A bit confusing...
Great tutorial!
thank you :)
Thanks for this video
glad you like it!
I love this channel. Thanks for sharing such great content
Thank you!
hey im having problem with my tinydb, when i tried running it i keep getting an error that says "cannot import name 'tinydb' from partially initialized module 'tinydb'". any help would be really appreciated:)
Is your import correct: from tinydb import TinyDB. Also make sure that you have NO file in your folder that is called tinydb.py
Nice video
Amazing Bro...
Thanks!
Thanks. Is there any Deep Learning related use case you have used it for? Just curious.
I haven't used it in a deep learning use case so far. I like to use it for example in small projects together with Flask
Hello !!
I'd like to know if I can use TinyDB with Flask to make it work everywhere for everyone
Yep!
@@Harry-uc4fo That be cool
First db.purge(), now db.write_back()... Though your video is not that old, it is already outdated. One thing that may be done: in the title, include the version of TinyDB the video is intended for.
db.truncate() worked for me.
Holy shit, this is so good explained!
thanks! glad to hear that :)
This doesn't make a lot of sense. If you're dealing with information that fits into a single JSON file, that's just not enough data to require a database.
Then don't consider it a database, consider it a way of keeping information and being able to recall it later.
Hi everyone. The video is great but I have some real probleme with Python or Python Community. Well, I come from javaScript and I am learning Python. This language seem like a mess (to be polite). Because purge() was replace by truncate but .write_back() has been remove AND THAT IT and other Python issue! How do you deal with this unstable language?
in this case this is not the problem of Python, but of this third party library tinyDB. Unfortunately it released a new version with breaking changes shortly after my video...
@@patloeber Ok thank you Patrick for your reply and for all your videos.
I created a table « Players »
Each players got « classement »
I tried so many times to change this « classement » but it’s impossible..
to find the player i use to write
Player_table = db.table(« players »)
Player_table.search(where(‘name’)==name)
Player_table.update({‘classement’:newclassement})
But nothing changed
The search has to be in a variable like
search = db.search(something == something)
search.update(something)