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! 🙏

КОМЕНТАРІ • 47

  • @machinimaaquinix3178
    @machinimaaquinix3178 4 роки тому +2

    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.

  • @zt.5677
    @zt.5677 3 роки тому

    This is very good. Solid stuff. The purge() > truncate() thing is not a problem at all. Thanks Patrick.

  • @tigron1530
    @tigron1530 3 роки тому

    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?

  • @noiseus_e
    @noiseus_e 3 роки тому

    how does one access these key values however? when you have {name: 'Max'}, how are you able to access Max

  • @a.amiracle2579
    @a.amiracle2579 3 роки тому

    Excellent explanation, thank you!

  • @madeggs5008
    @madeggs5008 Рік тому

    How do you get the age number insted of getting everything?

  • @heikoherrmann7196
    @heikoherrmann7196 Рік тому

    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?

  • @emporiummedia1012
    @emporiummedia1012 3 роки тому

    oh man this video just saved me from a huge headache, thanks

    • @patloeber
      @patloeber  3 роки тому

      glad to hear this :)

    • @emporiummedia1012
      @emporiummedia1012 3 роки тому

      @@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...

  • @DinaAshraf143
    @DinaAshraf143 3 роки тому

    Great tutorial!

  • @rachit6099
    @rachit6099 3 роки тому +1

    Thanks for this video

  • @abhijeetgupta2754
    @abhijeetgupta2754 4 роки тому +1

    I love this channel. Thanks for sharing such great content

  • @rezayusrilnaufal5319
    @rezayusrilnaufal5319 4 роки тому

    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:)

    • @patloeber
      @patloeber  4 роки тому

      Is your import correct: from tinydb import TinyDB. Also make sure that you have NO file in your folder that is called tinydb.py

  • @alavinexplore847
    @alavinexplore847 4 роки тому

    Nice video

  • @sultanakalsekar6800
    @sultanakalsekar6800 3 роки тому

    Amazing Bro...

  • @DanielWeikert
    @DanielWeikert 4 роки тому

    Thanks. Is there any Deep Learning related use case you have used it for? Just curious.

    • @patloeber
      @patloeber  4 роки тому +3

      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

  • @taninfilms3536
    @taninfilms3536 2 роки тому

    Hello !!
    I'd like to know if I can use TinyDB with Flask to make it work everywhere for everyone

  • @chachacha1289
    @chachacha1289 3 роки тому +3

    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.

    • @tehdoogie
      @tehdoogie 2 роки тому

      db.truncate() worked for me.

  • @qxch7222
    @qxch7222 3 роки тому

    Holy shit, this is so good explained!

    • @patloeber
      @patloeber  3 роки тому +1

      thanks! glad to hear that :)

  • @chaosordeal294
    @chaosordeal294 Рік тому

    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.

    • @brncray
      @brncray Рік тому +1

      Then don't consider it a database, consider it a way of keeping information and being able to recall it later.

  • @jeanyvesnadal4261
    @jeanyvesnadal4261 3 роки тому

    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?

    • @patloeber
      @patloeber  3 роки тому +1

      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...

    • @jeanyvesnadal4261
      @jeanyvesnadal4261 3 роки тому

      @@patloeber Ok thank you Patrick for your reply and for all your videos.

  • @nemutluturkumdiyeneasphixi9712
    @nemutluturkumdiyeneasphixi9712 2 роки тому

    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

    • @rancio3354
      @rancio3354 2 роки тому

      The search has to be in a variable like
      search = db.search(something == something)
      search.update(something)