Author: alien

  • Khóa học miễn phí TinyDB – Tables nhận dự án làm có lương

    Khóa học miễn phí TinyDB – Tables nhận dự án làm có lương


    TinyDB – Tables



    In TinyDB, we can work with multiple tables. These tables have the same properties as the TinyDB class. Let”s see how we can create tables in TinyDB and apply various operations on them −

    Creating Tables

    It’s very easy to create a table in TinyDB. Here”s its syntax −

    table_object = db.table(''table name'')
    

    Inserting Values in a Table

    To insert data in a specific table, use the following syntax −

    table_object.insert({ ''key'' : value })
    

    Retreiving Values from a Table

    To retrieve values from a table, use the following query −

    table_object.all()
    

    Deleting a Table from a Database

    To delete a table from a database, use the drop_table() query. Here is its syntax

    db.drop_table(''table name'')
    

    Delete Multiple Tables from a Database

    To delete multiple tables from a database, use the following query −

    db.drop_tables()
    

    Let”s understand how to use these queries with the help of a few examples. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Use the following code to create a new table called Student_Detail

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    table_object = db.table(''Student_Detail'')
    

    Example 2

    Next, let”s insert values in this new table Student_Detail

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    table_object = db.table(''Student_Detail'')
    table_object.insert({
       ''roll_number'': 1,
       ''st_name'': ''elen'',
       ''mark'': 250,
       ''subject'': ''TinyDB'',
       ''address'': ''delhi''
    })
    

    It will return the doc_id of the record inserted in the table.

    [1]
    

    To verify, use the following code −

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    table_object = db.table(''Student_Detail'')
    table_object.all()
    

    It will show data contained in the Student_Detail table −

    {''roll_number'': 1, ''st_name'': ''elen'', ''mark'': 250, ''subject'': ''TinyDB'', ''address'': ''delhi''}
    

    Example 3

    To see all the tables present in the database, use the following query −

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    print(db.tables())
    

    There are two tables inside “student.json”. It will show the names of these two tables −

    {''Student_Detail'', ''_default''}
    

    Example 4

    Let”s see how we can reterive all the values from a table −

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    table_object = db.table("Student_Detail")
    print(table_object.all())
    

    It will show the following output

    [{
       ''roll_number'': 1,
       ''st_name'': ''elen'',
       ''mark'': 250,
       ''subject'': ''TinyDB'',
       ''address'': ''delhi''
    }]
    

    Example 5

    Let”s see how we can remove a table from a database −

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    db.drop_table(''Student_Detail'')
    

    It will remove the “Student_Detail” table from the database. To remove all the tables from a database, use the “drop_tables()” query −

    db.drop_tables()
    

    It will remove all the tables from the database.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

    Khóa Học Miễn Phí TinyDB – Tables: Cơ Hội Nhận Dự Án Có Lương

    Trong thế giới quản lý cơ sở dữ liệu, việc nắm vững cách sử dụng và tổ chức dữ liệu là rất quan trọng, đặc biệt là khi làm việc với các hệ thống nhỏ gọn và dễ quản lý như TinyDB. Để giúp các bạn phát triển kỹ năng trong việc sử dụng TinyDB một cách hiệu quả, chúng tôi xin giới thiệu khóa học miễn phí “TinyDB – Tables”, đồng thời mở ra cơ hội nhận dự án làm có lương. Đây là cơ hội không thể bỏ qua cho những ai muốn nâng cao kỹ năng quản lý dữ liệu và có thêm thu nhập.

    khoa hoc mien phi TinyDB – Tables
    khoa hoc mien phi TinyDB – Tables

    Khóa Học TinyDB – Tables: Nội Dung Chính

    Khóa học “TinyDB – Tables” tập trung vào việc giúp học viên hiểu và làm việc với các bảng (tables) trong TinyDB. Nội dung của khóa học bao gồm:

    1. Giới Thiệu Về TinyDB và Tables: Khái quát về TinyDB và vai trò của các bảng trong việc tổ chức dữ liệu.
    2. Tạo và Quản Lý Bảng: Hướng dẫn chi tiết cách tạo bảng, định nghĩa cấu trúc bảng, và quản lý dữ liệu trong các bảng.
    3. Truy Xuất Dữ Liệu Trong Bảng: Các phương pháp truy xuất dữ liệu từ bảng, bao gồm các câu lệnh tìm kiếm và lọc.
    4. Tối Ưu Hóa Bảng: Kỹ thuật để tối ưu hóa hiệu suất khi làm việc với nhiều bảng và dữ liệu lớn.
    5. Ứng Dụng Thực Tế: Xây dựng ứng dụng thực tiễn sử dụng các bảng trong TinyDB để thực hành và củng cố kiến thức.
    khoa hoc mien phi TinyDB – Tables
    khoa hoc mien phi TinyDB – Tables

    Lợi Ích Khi Tham Gia Khóa Học

    1. Miễn Phí 100%: Khóa học hoàn toàn miễn phí, giúp bạn tiết kiệm chi phí học tập mà vẫn nhận được kiến thức chuyên sâu.
    2. Kỹ Năng Quản Lý Bảng: Bạn sẽ học cách tổ chức và quản lý dữ liệu hiệu quả, điều này rất hữu ích trong các dự án thực tế.
    3. Thực Hành Với Dự Án Thực Tế: Khóa học cung cấp cơ hội làm việc trên các dự án thực tế, giúp bạn áp dụng kiến thức vào các tình huống cụ thể.
    4. Nhận Dự Án Có Lương: Sau khi hoàn thành khóa học, bạn có thể nhận các dự án có lương để thực hành kỹ năng của mình, đồng thời kiếm thêm thu nhập.
    5. Hỗ Trợ Từ Giảng Viên: Đội ngũ giảng viên sẽ hỗ trợ và hướng dẫn bạn trong suốt khóa học, đảm bảo bạn có được kiến thức và kỹ năng cần thiết.
    khoa hoc mien phi TinyDB – Tables
    khoa hoc mien phi TinyDB – Tables

    Cơ Hội Nhận Dự Án Có Lương

    Một điểm nổi bật của khóa học “TinyDB – Tables” là cơ hội nhận các dự án có lương. Sau khi hoàn thành khóa học, bạn có thể tham gia vào các dự án thực tế liên quan đến TinyDB và các bảng của nó. Đây là cơ hội tuyệt vời để bạn áp dụng kiến thức vào công việc thực tế, đồng thời kiếm thêm thu nhập và tích lũy kinh nghiệm quý báu.

    khoa hoc mien phi TinyDB – Tables
    khoa hoc mien phi TinyDB – Tables

    Cách Đăng Ký

    Để tham gia khóa học, bạn có thể đăng ký qua trang web chính thức của khóa học hoặc liên hệ với đơn vị tổ chức để nhận hướng dẫn chi tiết. Đừng bỏ lỡ cơ hội học hỏi và phát triển kỹ năng quản lý bảng dữ liệu với TinyDB, đồng thời kiếm thêm thu nhập từ các dự án thực tế!

    Khóa học “TinyDB – Tables” không chỉ giúp bạn nắm vững kỹ năng quản lý dữ liệu trong TinyDB mà còn mở ra cơ hội nghề nghiệp hấp dẫn. Hãy đăng ký ngay hôm nay để bắt đầu hành trình học tập và phát triển nghề nghiệp của bạn!

    https://youtu.be/9DFRyQO_d_E?si=lZhgStcBGKutfxVg
  • Khóa học miễn phí TinyDB – Discussion nhận dự án làm có lương

    Khóa học miễn phí TinyDB – Discussion nhận dự án làm có lương


    TinyDB – Discussion



    TinyDB is a lightweight database to operate various formats of the document. It is an easy and hustles free database to handle data of several applications. TinyDB is based on python code and supports clean API. This database does not need any coding language. It handles small projects without any configurations. Generally, a database can store, retrieve, and modify data in a JSON file.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

    Khóa Học Miễn Phí TinyDB – Discussion: Cơ Hội Nhận Dự Án Làm Có Lương!

    Bạn đang tìm kiếm cơ hội để nâng cao kỹ năng quản lý cơ sở dữ liệu và tham gia vào các dự án thực tế? Khóa học miễn phí TinyDB – Discussion chính là lựa chọn lý tưởng dành cho bạn! Tham gia khóa học này không chỉ giúp bạn hiểu sâu về TinyDB mà còn mở ra cơ hội nhận các dự án làm việc có lương. Hãy cùng khám phá chi tiết về khóa học và những lợi ích mà nó mang lại!

    khoa hoc mien phi  TinyDB – Discussion
    khoa hoc mien phi TinyDB – Discussion

    Tại Sao Nên Tham Gia Khóa Học TinyDB – Discussion?

    TinyDB là một cơ sở dữ liệu NoSQL nhẹ và dễ sử dụng, phù hợp cho các dự án nhỏ và ứng dụng nhúng. Tuy nhiên, việc quản lý và triển khai TinyDB hiệu quả không chỉ yêu cầu kiến thức lý thuyết mà còn cần sự hiểu biết sâu sắc qua thảo luận và trao đổi kinh nghiệm.

    Khóa học TinyDB – Discussion sẽ cung cấp cho bạn:

    • Kiến Thức Chuyên Sâu: Nắm vững các khái niệm và kỹ thuật liên quan đến TinyDB qua các buổi thảo luận chi tiết.
    • Kinh Nghiệm Thực Tế: Học hỏi từ các tình huống thực tế và kinh nghiệm của những người đã làm việc với TinyDB.
    • Cơ Hội Thực Hành: Áp dụng các kiến thức vào các bài tập và dự án thực tế.
    khoa hoc mien phi  TinyDB – Discussion
    khoa hoc mien phi TinyDB – Discussion

    Nội Dung Khóa Học

    Khóa học TinyDB – Discussion bao gồm các nội dung chính sau:

    1. Giới Thiệu về TinyDB: Tổng quan về TinyDB và các ứng dụng của nó.
    2. Thảo Luận về Các Kỹ Thuật TinyDB: Tham gia các buổi thảo luận chi tiết về các kỹ thuật và phương pháp quản lý dữ liệu trong TinyDB.
    3. Giải Quyết Vấn Đề Thực Tế: Thảo luận về các tình huống và vấn đề thường gặp khi làm việc với TinyDB.
    4. Chia Sẻ Kinh Nghiệm: Học hỏi từ kinh nghiệm của các chuyên gia và đồng nghiệp trong cộng đồng TinyDB.
    5. Dự Án Thực Tế: Thực hành các kiến thức qua các bài tập và dự án thực tế.
    khoa hoc mien phi  TinyDB – Discussion
    khoa hoc mien phi TinyDB – Discussion

    Cơ Hội Nhận Dự Án Làm Có Lương

    Sau khi hoàn thành khóa học, bạn sẽ có cơ hội nhận các dự án thực tế có lương. Đây là một phần trong chương trình hỗ trợ học viên của chúng tôi, giúp bạn áp dụng kiến thức vào công việc thực tế và kiếm thêm thu nhập. Các dự án này sẽ được phân công dựa trên kỹ năng và sở thích của bạn, đảm bảo rằng bạn có thể làm việc hiệu quả và phát triển sự nghiệp trong lĩnh vực quản lý cơ sở dữ liệu.

    Cách Đăng Ký

    Để tham gia khóa học TinyDB – Discussion, bạn chỉ cần:

    1. Đăng Ký: Truy cập trang đăng ký trên website của chúng tôi và hoàn tất các bước đăng ký.
    2. Tham Gia Khóa Học: Tham gia các buổi thảo luận và hoàn thành các bài tập theo yêu cầu.
    3. Nhận Dự Án: Sau khi hoàn thành khóa học, bạn có thể đăng ký nhận các dự án có lương và bắt đầu thực hiện.
    khoa hoc mien phi  TinyDB – Discussion
    khoa hoc mien phi TinyDB – Discussion

    Đăng Ký Ngay Để Không Bỏ Lỡ!

    Khóa học TinyDB – Discussion hoàn toàn miễn phí và mở ra cơ hội để bạn nâng cao kỹ năng quản lý cơ sở dữ liệu và nhận các dự án thực tế có lương. Đừng bỏ lỡ cơ hội tuyệt vời này để phát triển sự nghiệp của bạn trong lĩnh vực quản lý cơ sở dữ liệu.

    https://www.youtube.com/watch?v=5I7XvTHG_mk&t=30s

    Hãy đăng ký ngay hôm nay và bắt đầu hành trình học tập và làm việc với TinyDB!


    Chúng tôi rất mong được đồng hành cùng bạn trong việc nâng cao kỹ năng và phát triển nghề nghiệp.

    Nếu bạn có bất kỳ câu hỏi nào hoặc cần thêm thông tin, vui lòng liên hệ với chúng tôi qua email hoặc trang hỗ trợ trên website.

  • Khóa học miễn phí TinyDB – Retrieving Data nhận dự án làm có lương

    Khóa học miễn phí TinyDB – Retrieving Data nhận dự án làm có lương


    TinyDB – Retrieving Data



    After creating a database, we need to frequently retrieve the data from that database. Following are the ways by which we can reterive the data from a database −

    The len() Query

    With the help of this query, we can get the number of documents in a database. Its syntax is as follows −

    len(db)
    

    The get Query

    The get query is used to reterive specific documents matching a query. Its syntax is as follows −

    db.get(query)
    

    The contains Query

    The contains query is used to check whether the database contains a matching value or not. Its syntax is as follows −

    db.contains(query)
    

    The count Query

    The count query is used to retrieve the number of matching documents from a database. Its syntax is as follows −

    db.count(query)
    

    Let”s take a few examples to understand how these queries work in TinyDB. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s see how we can use the len() query to get the number of documents in our database −

    from tinydb import TinyDB
    db = TinyDB(''student.json'')
    print ("Number of documents in student db: ", len(db))
    

    It will show the number of documents present in the specified database −

    Number of documents in student db: 5
    

    Example 2

    Let”s see how we can use the get() query to get a specific document from our database −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.get(Query().address == ''delhi'')
    

    This query will fetch the row where the “address” field has the value “delhi”.

    {
       ''roll_number'': 1,
       ''st_name'': ''elen'',
       ''mark'': 250,
       ''subject'': ''TinyDB'',
       ''address'': ''delhi''
    }
    

    Example 3

    Let”s see how we can use the contains() query to verify if our database contains a specific value −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.contains(Query().address == ''delhi'')
    

    The contains() query returns a Boolean value, based on the existence of the specified value in the given database. In this case, it will return “True” because our database does have a “address” key with the value “delhi”.

    True
    

    Example 4

    Let”s see how we can use the count() query to get the number of documents for which a given condition is True −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    print (db.count(Query().subject == ''NoSQL''))
    

    It will return the following output

    3
    

    It means there are 3 documents in the database where the “subject” key has the value “NoSQL”.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

    Khóa Học Miễn Phí TinyDB – Retrieving Data: Cơ Hội Nhận Dự Án Có Lương

    Trong thế giới công nghệ ngày nay, việc quản lý và truy xuất dữ liệu hiệu quả là rất quan trọng. Đặc biệt, đối với những người làm việc trong lĩnh vực phát triển phần mềm và phân tích dữ liệu, khả năng làm việc với cơ sở dữ liệu nhỏ gọn như TinyDB có thể mang lại nhiều lợi ích. Để hỗ trợ các bạn trong việc nắm bắt kỹ năng này, chúng tôi xin giới thiệu khóa học miễn phí về TinyDB với chủ đề “Retrieving Data”, đồng thời mở ra cơ hội nhận dự án làm có lương.

    khoa hoc mien phi TinyDB - Retrieving Data
    khoa hoc mien phi TinyDB – Retrieving Data

    Giới Thiệu Về TinyDB

    TinyDB là một thư viện cơ sở dữ liệu NoSQL dành cho Python, nổi bật với sự đơn giản và tính dễ sử dụng. Với TinyDB, bạn có thể lưu trữ dữ liệu dưới dạng JSON mà không cần phải thiết lập hoặc quản lý một hệ quản trị cơ sở dữ liệu phức tạp. TinyDB phù hợp cho các ứng dụng nhỏ, dự án cá nhân hoặc những người mới bắt đầu học về cơ sở dữ liệu.

    khoa hoc mien phi TinyDB - Retrieving Data
    khoa hoc mien phi TinyDB – Retrieving Data

    Nội Dung Khóa Học

    Khóa học miễn phí “Retrieving Data” tập trung vào việc giúp học viên hiểu và thực hành các kỹ thuật truy xuất dữ liệu cơ bản và nâng cao trong TinyDB. Nội dung chính của khóa học bao gồm:

    1. Giới Thiệu Cơ Bản Về TinyDB: Cài đặt, cấu hình và làm quen với các khái niệm cơ bản.
    2. Truy Xuất Dữ Liệu Đơn Giản: Các phương pháp truy xuất dữ liệu cơ bản như tìm kiếm theo điều kiện đơn giản.
    3. Truy Xuất Dữ Liệu Nâng Cao: Sử dụng các câu lệnh truy vấn phức tạp hơn, kết hợp nhiều điều kiện và các hàm hỗ trợ.
    4. Tối Ưu Hiệu Suất: Kỹ thuật tối ưu hóa truy vấn để xử lý hiệu quả các tập dữ liệu lớn.
    5. Ứng Dụng Thực Tiễn: Xây dựng ứng dụng thực tế sử dụng TinyDB để củng cố kỹ năng.
    khoa hoc mien phi TinyDB - Retrieving Data
    khoa hoc mien phi TinyDB – Retrieving Data

    Cơ Hội Nhận Dự Án Có Lương

    Một trong những điểm nổi bật của khóa học này là cơ hội nhận dự án làm có lương. Sau khi hoàn thành khóa học, các học viên có thể tham gia vào các dự án thực tế và nhận thù lao cho công việc của mình. Đây là cơ hội tuyệt vời để áp dụng những gì đã học vào thực tế, đồng thời kiếm thêm thu nhập và tích lũy kinh nghiệm quý báu.

    khoa hoc mien phi TinyDB - Retrieving Data
    khoa hoc mien phi TinyDB – Retrieving Data

    Lợi Ích Khi Tham Gia Khóa Học

    1. Miễn Phí 100%: Bạn sẽ không phải bỏ ra bất kỳ khoản phí nào để tham gia khóa học.
    2. Cơ Hội Thực Hành: Các bài tập và dự án thực tế giúp bạn củng cố kiến thức và kỹ năng.
    3. Nhận Dự Án Có Lương: Cơ hội nhận thù lao cho công việc thực tế sau khi hoàn thành khóa học.
    4. Hỗ Trợ Từ Giảng Viên: Đội ngũ giảng viên giàu kinh nghiệm sẵn sàng hỗ trợ bạn trong suốt quá trình học.
    khoa hoc mien phi TinyDB - Retrieving Data
    khoa hoc mien phi TinyDB – Retrieving Data

    Cách Đăng Ký

    Để tham gia khóa học, bạn chỉ cần đăng ký qua trang web chính thức của khóa học hoặc liên hệ với đơn vị tổ chức để được hướng dẫn thêm. Đừng bỏ lỡ cơ hội học hỏi và phát triển kỹ năng trong lĩnh vực cơ sở dữ liệu nhỏ gọn với TinyDB!

    Khóa học “Retrieving Data” với TinyDB không chỉ cung cấp kiến thức chuyên sâu về truy xuất dữ liệu mà còn mở ra cơ hội nghề nghiệp hấp dẫn. Hãy đăng ký ngay hôm nay để không bỏ lỡ cơ hội tuyệt vời này!

    https://www.youtube.com/live/IUTS24LTzpU?si=25pEKciS1GbxFheO
  • Khóa học miễn phí TinyDB – Caching Query nhận dự án làm có lương

    Khóa học miễn phí TinyDB – Caching Query nhận dự án làm có lương


    TinyDB – Caching Query



    Catching query is an advanced feature of TinyDB with the help of which it caches the query result for performance optimization. In this way, when we run the same query again, TinyDB doesn”t need to read the data from the storage. We can pass the cache_size to the table function to optimize the query cache size.

    Syntax

    The syntax of TinyDB query caching is shown below −

    table = db.table(''table_name'', cache_size=value)
    

    Example

    TinyDB creates cache size memory in given table.

    from tinydb import TinyDB
    db = TinyDB(''student.json'')
    objects = db.table(''Student_Detail'', cache_size = 50)
    objects.all()
    

    It will produce the following output. Observe that cache size does not affect the table values.

    [{
       ''roll_number'': 1,
       ''st_name'': ''elen'',
       ''mark'': 250,
       ''subject'': ''TinyDB'',
       ''address'': ''delhi''
    }]
    

    We can set unlimited cache size by putting “cache_size = None”.

    objects = db.table(''Student_Detail'', cache_size = None)
    

    We can also disable the cache size by putting “cache_size = 0”.

    objects = db.table(''Student_Detail'', cache_size = 0)
    

    To clear the cache size, use the following query −

    db.clear_cache()
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

    Khóa Học Miễn Phí TinyDB – Caching Query: Cơ Hội Nhận Dự Án Làm Có Lương!

    Bạn có biết rằng tối ưu hóa truy vấn dữ liệu có thể tạo ra sự khác biệt lớn trong hiệu suất của ứng dụng? Nếu bạn muốn học cách cải thiện tốc độ và hiệu quả của các truy vấn trong TinyDB, thì khóa học miễn phí TinyDB – Caching Query chính là cơ hội tuyệt vời dành cho bạn! Tham gia khóa học này không chỉ giúp bạn làm chủ kỹ thuật caching mà còn mở ra cơ hội nhận các dự án thực tế có lương. Hãy cùng khám phá chi tiết về khóa học này và cách nó có thể giúp bạn phát triển sự nghiệp!

    khoa hoc mien phi TinyDB – Caching Query
    khoa hoc mien phi TinyDB – Caching Query

    Tại Sao Nên Tham Gia Khóa Học TinyDB – Caching Query?

    TinyDB là một cơ sở dữ liệu NoSQL nhẹ và linh hoạt, thường được sử dụng cho các ứng dụng nhỏ và nhúng. Tuy nhiên, việc tối ưu hóa truy vấn dữ liệu trong TinyDB có thể là một thách thức, đặc biệt là khi làm việc với lượng dữ liệu lớn hoặc các yêu cầu phức tạp.

    Khóa học TinyDB – Caching Query sẽ giúp bạn:

    • Tìm Hiểu Kỹ Thuật Caching: Cách sử dụng caching để tăng tốc độ truy vấn và cải thiện hiệu suất của ứng dụng.
    • Áp Dụng Vào TinyDB: Hướng dẫn chi tiết về cách tích hợp caching vào TinyDB.
    • Thực Hành Tinh Thông: Áp dụng các kỹ thuật caching vào các bài tập và dự án thực tế.
    khoa hoc mien phi TinyDB – Caching Query
    khoa hoc mien phi TinyDB – Caching Query

    Nội Dung Khóa Học

    Khóa học TinyDB – Caching Query bao gồm các nội dung chính sau:

    1. Giới Thiệu về TinyDB: Tổng quan về TinyDB và cách hoạt động của nó.
    2. Khái Niệm Về Caching: Tìm hiểu các khái niệm cơ bản về caching và lợi ích của nó trong quản lý dữ liệu.
    3. Tối Ưu Hóa Truy Vấn Với Caching: Cách sử dụng caching để cải thiện hiệu suất của các truy vấn trong TinyDB.
    4. Kỹ Thuật Caching Trong TinyDB: Hướng dẫn chi tiết về cách áp dụng caching vào TinyDB.
    5. Dự Án Thực Tế: Thực hành các kỹ thuật caching qua các bài tập và dự án thực tế.
    khoa hoc mien phi TinyDB – Caching Query
    khoa hoc mien phi TinyDB – Caching Query

    Cơ Hội Nhận Dự Án Làm Có Lương

    Sau khi hoàn thành khóa học, bạn có cơ hội nhận các dự án thực tế có lương. Đây là một phần trong chương trình hỗ trợ học viên của chúng tôi, nhằm giúp bạn áp dụng kiến thức vào công việc thực tế và kiếm thêm thu nhập. Các dự án này được thiết kế để phù hợp với kỹ năng và sở thích của bạn, đảm bảo bạn có thể làm việc hiệu quả và phát triển sự nghiệp trong lĩnh vực quản lý cơ sở dữ liệu và tối ưu hóa hiệu suất.

    khoa hoc mien phi TinyDB – Caching Query
    khoa hoc mien phi TinyDB – Caching Query

    Cách Đăng Ký

    Để tham gia khóa học TinyDB – Caching Query, bạn chỉ cần:

    1. Đăng Ký: Truy cập trang đăng ký trên website của chúng tôi và hoàn tất thông tin cần thiết.
    2. Tham Gia Khóa Học: Theo dõi lịch trình học tập và hoàn thành các bài tập theo yêu cầu.
    3. Nhận Dự Án: Sau khi hoàn thành khóa học, bạn có thể đăng ký nhận các dự án làm việc có lương và bắt đầu thực hiện.

    Đăng Ký Ngay Để Không Bỏ Lỡ!

    Khóa học TinyDB – Caching Query hoàn toàn miễn phí và mở ra cơ hội để bạn nâng cao kỹ năng tối ưu hóa truy vấn dữ liệu và nhận các dự án thực tế có lương. Đừng bỏ lỡ cơ hội tuyệt vời này để phát triển sự nghiệp của bạn trong lĩnh vực quản lý cơ sở dữ liệu.

    https://www.youtube.com/watch?v=TJau6F_CyNw&t=40s

    Hãy đăng ký ngay hôm nay và bắt đầu hành trình học tập và làm việc với TinyDB!


    Chúng tôi rất mong được đồng hành cùng bạn trong việc nâng cao kỹ năng và phát triển nghề nghiệp.

    Nếu bạn có bất kỳ câu hỏi nào hoặc cần thêm thông tin, vui lòng liên hệ với chúng tôi qua email hoặc trang hỗ trợ trên website.

  • Khóa học miễn phí TinyDB – Extensions nhận dự án làm có lương

    Khóa học miễn phí TinyDB – Extensions nhận dự án làm có lương


    TinyDB – Extensions



    Given below is a set of TinyDB extensions that can be used for various operations −

    Sr.No. Operation & Description
    1 TinyDBTimestamps

    It is an experimental extension that can be used to automatically add and update at timestamps to TinyDB documents.

    2 aiotinydb

    It is a stable extension that enables us to use TinyDB in asyncio-aware contexts without slowing done the synchromous Input/Output(I/O).

    3 tinydb – smartcache

    It is also a stable extension. It provides users with a smart query cache. It automatically updates the query cache so that the cache does not get invalidated after inserting, updating, or removing any documents.

    4 tinydb – serialization

    It is a stable extension that provides serialization of the database object.

    5 tinydb – appengine

    It provides storage for App Engine. It is also a stable extension.

    6 Tinyrecord

    A stable extension that implements experimental atomic transaction support for the TinyDB NoSQL DB.

    7 TinyMP

    It is also stable extension used for storage based on the MessagePack.

    8 Tinymongo

    It is an experimental extension which is used for the replacement of MongoDB.

    9 Tinyindex

    It is also an experimental extension of the database. As name implies, it is used for indexing data of the database.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

    Khóa Học Miễn Phí “TinyDB – Extensions”: Khám Phá Các Tính Năng Mở Rộng Và Nhận Dự Án Có Lương

    Bạn đang tìm cách mở rộng khả năng sử dụng TinyDB và muốn có cơ hội nhận các dự án thực tế với mức lương hấp dẫn? Khóa học miễn phí “TinyDB – Extensions” chính là lựa chọn hoàn hảo dành cho bạn. Khóa học này được thiết kế để giúp bạn khai thác các tính năng mở rộng của TinyDB, từ đó nâng cao khả năng làm việc với cơ sở dữ liệu và mở ra nhiều cơ hội nghề nghiệp.

    khoa hoc mien phi : "TinyDB - Extensions"
    khoa hoc mien phi : “TinyDB – Extensions”

    Nội Dung Khóa Học

    Khóa học “TinyDB – Extensions” tập trung vào việc mở rộng và tùy chỉnh TinyDB để đáp ứng các nhu cầu cụ thể. Bạn sẽ được học:

    • Giới Thiệu về Các Extensions: Tìm hiểu về các phần mở rộng có sẵn cho TinyDB và cách chúng có thể cải thiện chức năng của cơ sở dữ liệu.
    • Cài Đặt và Sử Dụng Extensions: Hướng dẫn chi tiết cách cài đặt và tích hợp các extensions vào dự án của bạn.
    • Tạo Extensions Tùy Chỉnh: Học cách phát triển các phần mở rộng tùy chỉnh để đáp ứng nhu cầu cụ thể của bạn hoặc của khách hàng.
    • Ví Dụ Thực Tiễn: Áp dụng các kiến thức vào các bài tập thực tế để giải quyết các bài toán cơ sở dữ liệu phức tạp.
    khoa hoc mien phi : "TinyDB - Extensions"
    khoa hoc mien phi : “TinyDB – Extensions”

    Tại Sao Nên Tham Gia?

    1. Miễn Phí và Linh Hoạt: Khóa học hoàn toàn miễn phí và có thể truy cập trực tuyến, giúp bạn học theo tốc độ của riêng mình mà không cần lo lắng về chi phí.
    2. Kỹ Năng Tinh Chỉnh: Việc học cách sử dụng và phát triển extensions cho TinyDB giúp bạn có thêm kỹ năng quan trọng, từ đó nâng cao khả năng làm việc với các cơ sở dữ liệu phức tạp hơn.
    3. Cơ Hội Nhận Dự Án Có Lương: Sau khi hoàn thành khóa học, bạn sẽ có cơ hội tham gia vào các dự án thực tế với mức lương hấp dẫn. Đây là cơ hội tuyệt vời để áp dụng kiến thức của bạn vào thực tiễn và xây dựng hồ sơ nghề nghiệp ấn tượng.
    khoa hoc mien phi : "TinyDB - Extensions"
    khoa hoc mien phi : “TinyDB – Extensions”

    Tận Dụng Cơ Hội

    Khóa học “TinyDB – Extensions” không chỉ giúp bạn mở rộng kiến thức về TinyDB mà còn tạo cơ hội để bạn phát triển nghề nghiệp thông qua các dự án thực tế. Đừng bỏ lỡ cơ hội này để nâng cao kỹ năng, làm việc với các dự án thực tế và nhận mức lương xứng đáng với những gì bạn đã học.

    Hãy đăng ký khóa học ngay hôm nay để khám phá các tính năng mở rộng của TinyDB và mở ra cánh cửa cơ hội nghề nghiệp mới. Đặt chân vào thế giới của cơ sở dữ liệu tiên tiến và thực hiện các dự án đầy thách thức ngay bây giờ!

    khoa hoc mien phi : "TinyDB - Extensions"
    khoa hoc mien phi : “TinyDB – Extensions”

    Tạo Nền Tảng Vững Chắc Cho Sự Nghiệp

    Khóa học “TinyDB – Extensions” không chỉ là cơ hội để học tập và nhận dự án có lương, mà còn là bước đầu quan trọng trong việc xây dựng nền tảng vững chắc cho sự nghiệp của bạn trong lĩnh vực phát triển phần mềm. Kỹ năng về các phần mở rộng của TinyDB sẽ giúp bạn tự tin hơn trong việc giải quyết các vấn đề phức tạp, đồng thời làm nổi bật hồ sơ nghề nghiệp của bạn trước các nhà tuyển dụng và khách hàng.

    Việc thành thạo các kỹ thuật mở rộng và tùy chỉnh TinyDB không chỉ mở rộng khả năng của bạn trong việc xử lý dữ liệu mà còn chứng tỏ bạn là một người có khả năng ứng dụng linh hoạt các công nghệ cơ sở dữ liệu để đáp ứng nhu cầu đa dạng. Đây là một lợi thế lớn trong ngành công nghiệp công nghệ thông tin, nơi sự sáng tạo và khả năng giải quyết vấn đề luôn được đánh giá cao.

    khoa hoc mien phi : "TinyDB - Extensions"
    khoa hoc mien phi : “TinyDB – Extensions”

    Hãy nắm bắt cơ hội học hỏi và phát triển này ngay hôm nay. Đăng ký khóa học “TinyDB – Extensions” để trang bị cho mình những kỹ năng cần thiết và bắt đầu hành trình tạo ra các giải pháp cơ sở dữ liệu đột phá. Đừng quên rằng mỗi kiến thức mới bạn học được chính là một bước tiến gần hơn đến thành công trong sự nghiệp của bạn.

    https://youtu.be/aAXjHvBFfT8?si=p4eitWB4oHymGtz_
  • Khóa học miễn phí TinyDB – Default Table nhận dự án làm có lương

    Khóa học miễn phí TinyDB – Default Table nhận dự án làm có lương


    TinyDB – Default Table



    TinyDB provides a default table in which it automatically saves and modifies the data. We can also set a table as the default table. The basic queries, methods, and operations will work on that default table. In this chapter, let”s see how we can see the tables in a database and how we can set a table of our choice as the default table −

    Showing the Tables in a Database

    To get the list of all the tables in a database, use the following code −

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    db.tables()
    

    It will produce the following output: We have two tables inside “student.json”, hence it will show the names of these two tables −

    {''Student_Detail'', ''_default''}
    

    The output shows that we have two tables in our database, one is “Student_Detail” and the other “_default”.

    Displaying the Values of the Default Table

    If you use the all() query, it will show the contents of the default table −

    from tinydb import TinyDB
    db = TinyDB("student.json")
    db.all()
    

    To show the contents of the “Student_Detail” table, use the following query −

    from tinydb import TinyDB
    db = TinyDB("student.json")
    print(db.table("Student_Detail").all())
    

    It will show the contents of the “Student_Detail” table −

    [{
       ''roll_number'': 1,
       ''st_name'': ''elen'',
       ''mark'': 250,
       ''subject'': ''TinyDB'',
       ''address'': ''delhi''
    }]
    

    Setting a Default Table

    You can set a table of your choice as the default table. For that, you need to use the following code −

    from tinydb import TinyDB
    db = TinyDB("student.json")
    db.default_table_name = "Student_Detail"
    

    It will set the “Student_Detail” table as the default table for our database.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

    Khóa Học Miễn Phí TinyDB – Default Table: Cơ Hội Nhận Dự Án Làm Có Lương!

    Bạn có muốn nắm vững cách quản lý các bảng dữ liệu trong TinyDB và tối ưu hóa quy trình làm việc của mình? Khóa học miễn phí TinyDB – Default Table chính là cơ hội lý tưởng dành cho bạn! Tham gia khóa học này không chỉ giúp bạn hiểu sâu về các bảng dữ liệu mặc định trong TinyDB mà còn mở ra cơ hội nhận các dự án thực tế có lương. Hãy cùng khám phá chi tiết về khóa học và những lợi ích mà nó mang lại!

    khoa hoc mien phi TinyDB – Default Table
    khoa hoc mien phi TinyDB – Default Table

    Tại Sao Nên Tham Gia Khóa Học TinyDB – Default Table?

    TinyDB là một cơ sở dữ liệu NoSQL nhẹ, dễ sử dụng và lý tưởng cho các ứng dụng nhỏ và nhúng. Hiểu rõ cách sử dụng và quản lý các bảng dữ liệu mặc định (default tables) là yếu tố quan trọng để khai thác tối đa khả năng của TinyDB. Khóa học TinyDB – Default Table sẽ cung cấp cho bạn những kiến thức cần thiết để làm việc hiệu quả với các bảng dữ liệu trong TinyDB.

    Khóa học này sẽ cung cấp cho bạn:

    • Kiến Thức Về Default Tables: Hiểu rõ về cách TinyDB sử dụng và quản lý các bảng dữ liệu mặc định.
    • Kỹ Năng Quản Lý Bảng Dữ Liệu: Học cách cấu hình, tùy chỉnh và tối ưu hóa các bảng dữ liệu trong TinyDB.
    • Thực Hành Tinh Thông: Áp dụng kiến thức vào các bài tập và dự án thực tế để củng cố kỹ năng.
    khoa hoc mien phi TinyDB – Default Table
    khoa hoc mien phi TinyDB – Default Table

    Nội Dung Khóa Học

    Khóa học TinyDB – Default Table bao gồm các nội dung chính sau:

    1. Giới Thiệu về TinyDB: Tìm hiểu về cấu trúc cơ bản và các tính năng của TinyDB.
    2. Khái Niệm về Default Tables: Định nghĩa và vai trò của các bảng dữ liệu mặc định trong TinyDB.
    3. Quản Lý Bảng Dữ Liệu: Hướng dẫn chi tiết về cách tạo, cấu hình, và quản lý các bảng dữ liệu mặc định.
    4. Tối Ưu Hóa Hiệu Suất: Cách tối ưu hóa việc sử dụng các bảng dữ liệu để cải thiện hiệu suất và khả năng mở rộng.
    5. Dự Án Thực Tế: Áp dụng các kiến thức vào các bài tập và dự án thực tế để nâng cao kỹ năng.
    khoa hoc mien phi TinyDB – Default Table
    khoa hoc mien phi TinyDB – Default Table

    Cơ Hội Nhận Dự Án Làm Có Lương

    Sau khi hoàn thành khóa học, bạn có cơ hội nhận các dự án thực tế có lương. Đây là một phần trong chương trình hỗ trợ học viên của chúng tôi, nhằm giúp bạn áp dụng kiến thức vào công việc thực tế và kiếm thêm thu nhập. Các dự án này sẽ được phân công dựa trên kỹ năng và sở thích của bạn, đảm bảo bạn có thể làm việc hiệu quả và phát triển sự nghiệp trong lĩnh vực quản lý cơ sở dữ liệu.

    Cách Đăng Ký

    Để tham gia khóa học TinyDB – Default Table, bạn chỉ cần:

    1. Đăng Ký: Truy cập trang đăng ký trên website của chúng tôi và hoàn tất các bước đăng ký.
    2. Tham Gia Khóa Học: Theo dõi lịch trình học tập và hoàn thành các bài tập theo yêu cầu.
    3. Nhận Dự Án: Sau khi hoàn thành khóa học, bạn có thể đăng ký nhận các dự án làm việc có lương và bắt đầu thực hiện.
    khoa hoc mien phi TinyDB – Default Table
    khoa hoc mien phi TinyDB – Default Table

    Đăng Ký Ngay Để Không Bỏ Lỡ!

    Khóa học TinyDB – Default Table hoàn toàn miễn phí và mở ra cơ hội để bạn nâng cao kỹ năng quản lý cơ sở dữ liệu và nhận các dự án thực tế có lương. Đừng bỏ lỡ cơ hội tuyệt vời này để phát triển sự nghiệp của bạn trong lĩnh vực quản lý cơ sở dữ liệu.

    https://www.youtube.com/watch?v=5I7XvTHG_mk&t=30s

    Hãy đăng ký ngay hôm nay và bắt đầu hành trình học tập và làm việc với TinyDB!


    Chúng tôi rất mong được đồng hành cùng bạn trong việc nâng cao kỹ năng và phát triển nghề nghiệp.

    Nếu bạn có bất kỳ câu hỏi nào hoặc cần thêm thông tin, vui lòng liên hệ với chúng tôi qua email hoặc trang hỗ trợ trên website.

  • Khóa học miễn phí TinyDB – Quick Guide nhận dự án làm có lương

    Khóa học miễn phí TinyDB – Quick Guide nhận dự án làm có lương


    TinyDB – Quick Guide



    TinyDB – Introduction

    What is TinyDB?

    TinyDB, written in pure Python programming language, is a small and lightweight document-orineted database with no external dependencies. It provides simple APIs that makes it easy to use. We can use TinyDB database for small project applications without any configuration.

    TinyDB module, available as a third-party module for Python programs, can be used to store, retereive, and modify the data in JSON format.

    Features of TinyDB

    TinyDB is a clean and hustle-free database to operate several formats of documents. It has the following features.

    • Really tiny − TinyDB database is truly tiny in nature with only 1800 lines of code and 1600 lines tests.

    • Easy to use − TinyDB is easy to use because of its simple and clean APIs.

    • Document oriented − In TinyDB, we can store any document. The document will be represented as dict.

    • Independent − The TinyDB database is independent of any external server and external dependencies from PyPI.

    • Compatible with Python 3.6 or latest − TinyDB is tested and compatible with Python 3.6 and latest. It also works fine with PyPY3.

    • Extensible − TinDB is easily extensible either by writing new storages or by modifying the behaviour of storages.

    Advantages of TinyDB

    TinyDB provide various benefits for students, users, and developers.

    • TinyDB is open-sourced database aand it does not require any external configirations.

    • It is quite easy-to-use, and the user can effortlessly handle documents.

    • It automatically stores documents in the database.

    • TinyDB is ideal in case of personal projects where we need to install some data.

    • It is suitable for small applications that would be blown away by large databases like SQL or an external DB server.

    • It uses a simple command line and query to operate data.

    • There is 100% test coverage i.e., no explanation needed.

    Limitatations of TinyDB

    TinyDB will not be the right choice for your project if you need to −

    • create indexes for tables,

    • manage relationships between tables,

    • use an HTTP server, or

    • access from multiple processors.

    Comparison with Other Databases

    The following table highlights how TinyDB is different from MySQL and Oracle databases −

    Comparison Basis MySQL Oracle TinyDB
    Configurations Several Configurations Several Configurations Less Configurations, lightweight database
    Complicated Yes Yes No, easy-to-use and hustle-free
    Affordable No No Affordable than other databases
    Manageable Big database, hence difficult to manage Big database, hence difficult to manage Small and manageable

    TinyDB – Environmental Setup

    Prerequisite for TinyDB setup

    To install TinyDB, you must have Python 3.6 or newer installed in your system. You can go to the link and select the latest version for your OS, i.e., Windows and Linux/Unix. We have a comprehensive tutorial on Python, which you can refer at

    Installing TinyDB

    You can install TinyDB in three different ways: using the Pack Manager, from its Source, or from GitHub.

    Using the Package Manager

    The latest release versions of TinyDB are available over both the package managers, pip and conda. Let us check how you can use them to install TinyDB −

    To install TinyDB using pip, you can use the following command −

    pip install tinydb
    

    To install TinyDB via conda-forge, you can use the following command −

    conda install -c conda-forge tinydb
    

    From Source

    You can also install TinyDB from source distribution. Go to link to download the files and building it from source.

    From GitHub

    To install TinyDB using GitHub, grab the latest development version, unpack the files, and use the following command to install it −

    pip install
    

    Setting up TinyDB

    Once installed, use the following steps to set up the TinyDB database.

    Step 1: Import TinyDB and its Query

    First, we need to import TinyDB and its Query. Use the following command −

    from tinydb import TinyDB, Query
    

    Step 2: Create a file

    TinyDB database can store data in many formats like XML, JSON, and others. We will be creating a JSON file by using the following file −

    db = TinyDB(''Leekha.json'')
    

    The above command will create an instance of TinyDB class and pass the file Leekha.Json to it. This is the file where our data will be stored. Now, the TinyDB database set up is ready, and you can work on it. We can now insert data and operate the value in the database.

    Uinstalling TinyDB

    If in case you need to uninstall TinyDB, you can use the following command −

    pip uninstall tinydb
    

    TinyDB – Insert Data

    We have created the instance of the TinyDB and passed a JSON file to it where our data will be stored. It is now time to insert the items in our database. The data should be in the form of a Python dictionary.

    Syntax

    To insert an item, you can use insert() method whose syntax is given below −

    db.insert({''type1'': ''value1'', ''type2'': ''value2'', ''typeN'': ''valueN''})
    

    We can also create a dictionary first and then use the insert() method to insert the data into our database.

    data_item = {''type1'': ''value1'', ''type2'': ''value2'', ''typeN'': ''valueN'' } db.insert(data_item)
    

    After running the above command, the insert() method will return the ID of the newly created object. And, our JSON file will look like the one shown below −

    {"_default": {"1": {"type1": "value1", "type2": "value2", "typeN": "valueN"}}}
    

    Look at the above table entries: ”default” is the name of the table, ”1” is the ID of the newly created object, and the values are the data we have just inserted.

    Example: Inserting a Single Item

    Let”s understand the above concept with the help of examples. Suppose we have a database having student information showing roll numbers, names, marks, subjects, and addresses. Following is the information stored in the database −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"oracle",
          "address":"benglore"
       }
    ]
    

    In the above database, if you want to insert a new student record (i.e., a single item), use the following command −

    db.insert({
       ''roll_number'': 6,
       ''st_name'':''jim'',
       ''mark'':300,
       ''subject'':''sql'',
       ''address'':''pune''
    })
    

    It will return the ID of the newly created object −

    6
    

    Let”s enter one more record

    db.insert({
       ''roll_number'': 7,
       ''st_name'':''karan'',
       ''mark'':290,
       ''subject'':''NoSQL'',
       ''address'':''chennai''
    })
    

    It will return the ID of the newly created object −

    7
    

    If you want to check the stored items in the database, use the all() method as follows −

    db.all()
    

    It will produce the following output

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"oracle",
          "address":"benglore"
       },
       {
          "roll_number":6,
          "st_name":"jim",
          "mark":300,
          "subject":"sql",
          "address":"pune"
       },
       {
          "roll_number":7,
          "st_name":"karan",
          "mark":290,
          "subject":"NoSQL",
          "address":"chennai"
       }
    ]
    

    You can observe that it added two new data items in the JSON file.

    Example: Inserting Multiple items at a Time

    You can also insert multiple items at a time in a TinyDB database. For this, you need to use the insert_multiple() method. Let” see an example −

    items = [
       {''roll_number'': 8, ''st_name'': ''petter'', ''address'': ''mumbai''},
       {''roll_number'': 9, ''st_name'': ''sadhana'', ''subject'': ''SQL''}
    ]
    db.insert_multiple(items)
    

    Now, check the stored items in database, using the all() method as follows −

    db.all()
    

    It will produce the following output

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"oracle",
          "address":"benglore"
       },
       {
          "roll_number":6,
          "st_name":"jim",
          "mark":300,
          "subject":"sql",
          "address":"pune"
       },
       {
          "roll_number":7,
          "st_name":"karan",
          "mark":290,
          "subject":"NoSQL",
          "address":"chennai"
       },
       {
          "roll_number":8,
          "st_name":"petter",
          "address":"mumbai"
       },
       {
          "roll_number":9,
          "st_name":"sadhana",
          "subject":"SQL"
       }
    ]
    

    You can observe that it added two new data items in the JSON file. You can also skip some key values from the dataitems (as we have done) while adding the last two items. We have skipped ”mark” and ”address”.

    TinyDB – Retrieve Data

    There are numerous ways with the help of which you can retrieve data from a TinyDB database. But to use those ways, you first need to create an instance of the Query class as follows −

    from tinydb import Query
    Student = Query()
    

    Here, Student is the name of the database.

    Let”s check the various ways to retrieve the information from a TinyDB database.

    Data Retrieval Using the Search() Method

    The search() method, as its name implies, returns the list of items that mathches the query we provided, otherwise it will return an empty list.

    For this and other examples, we will be using the following student database data −

    [
       {
          "roll_number": 1,
          "st_name": "elen",
          "mark": 250,
          "subject": "TinyDB",
          "address": "delhi"
       },
       {
          "roll_number": 2,
          "st_name": "Ram",
          "mark": [
             250,
             280
          ],
          "subject": [
             "TinyDB",
             "MySQL"
          ],
          "address": "delhi"
       },
       {
          "roll_number": 3,
          "st_name": "kevin",
          "mark": [
             180,
             200
          ],
          "subject": [
             "oracle",
             "sql"
          ],
          "address": "keral"
       },
       {
          "roll_number": 4,
          "st_name": "lakan",
          "mark": 200,
          "subject": "MySQL",
          "address": "mumbai"
       },
       {
          "roll_number": 5,
          "st_name": "karan",
          "mark": 275,
          "subject": "TinyDB",
          "address": "benglore"
       }
    ]
    

    Let”s take an example to understand the search() method −

    from tinydb import TinyDB, Query
    db = TinyDB("leekha.json")
    student = Query()
    db.search(student.subject == ''TinyDB'' )
    

    The above query will retrieve the the following output from the student database −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    Data Retrieval Using the get() Method

    As opposed to the search() method, the get() method returns only one matching document. It will return None, otherwise. For example, let”s take the following code −

    from tinydb import TinyDB, Query
    student = Query()
    db.get(student.subject == ''TinyDB'' )
    

    The above query will retrieve the following data from the student database.

    [{''roll_number'': 1, ''st_name'': ''elen'', ''mark'': 250, ''subject'': ''TinyDB'', ''address'': ''delhi''}]
    

    Data Retrieval using the all() Method

    The all() method returns all the documents in the database. For example,

    db.all()
    

    It will retrieve the entire data from the student database.

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    Data Retrieval Using the for Loop

    The for loop also returns all the documents in the database. For example,

    for info in db:
       print(info)
    

    Just like the all() method, it will retrieve all the rows from the student database.

    TinyDB – Update Data

    TinyDB can store data in many formats and we can easily reterive the stored data using various methods. But sometimes, we need to update the data, for which we can use the update() method.

    For updating the database, we first need to create an instance of the Query class. You can use the following command for this purpose −

    from tinydb import Query
    Student = Query()
    

    Here, Student is the name of our database.

    The update() Method

    Here is the syntax for the update() method −

    db.update({ updated field: updated information… }, stable field: information)
    

    Let”s take an example to understand how the update() method works. For this example, we will be using the following student database −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    As per the given data, the name of the student with the roll_number “1” is “elen”. The following query will update the student name to “Adam” −

    from tinydb import TinyDB, Query
    student = Query()
    db.update({''st_name'' : ''Adam''}, student.roll_number == 1 )
    

    It will return the id of the updated object −

    [1]
    

    Now, you can use the all() method to see the updated database −

    db.all()
    

    It will display the updated data −

    [
       {
          "roll_number":1,
          "st_name":"Adam",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    Sometimes, we need to update one or more fields of all the documents in a database. For this, we can use the update() mehod directly and don”t need to write the query argument. The following query will change the address of all the students to ”College_Hostel”−

    db.update({''address'': ''College_Hostel''})
    

    It will return the ids of the updated object −

    [1,2,3,4,5]
    

    Again, you can use the all() method to see the updated database.

    db.all()
    

    It will show the updated data −

    [
       {
          "roll_number":1,
          "st_name":"Adam",
          "mark":250,
          "subject":"TinyDB",
          "address":"College_Hostel"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":" College_Hostel "
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":" College_Hostel "
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":" College_Hostel "
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":" College_Hostel "
       }
    ]
    

    Observe that the address fields of all the rows have the same data, i.e., ”College_Hostel”.

    TinyDB – Delete Data

    In case you need to delete a particular set of data permanently from a TinyDB database, you can do so by using the remove() method. Like for reteriving and updating the data, you first need to create an instance of the Query class for deleting the data. You can use the following command for this purpose −

    from tinydb import Query
    Student = Query()
    

    Here, Student is the name of our database.

    The remove() Method

    Here is the syntax for the remove() method −

    db.remove( Query() field regex )
    

    The remove() method accepts both an optional condition as well as an optional list of documents IDs.

    The student Database

    We will use the following student database, for the examples in this chapter.

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    Example: Deleting a Single Row of Data

    Let”s take an example to understand the remove() method.

    from tinydb import TinyDB, Query
    student = Query()
    db.remove(student.roll_number == 5)
    

    The above query will delete the data where the student”s roll number is 5. It will return the ID of the removed object −

    [5]
    

    Now, we can use the all() method to see the updated database.

    db.all()
    

    It will display the data from the updated database −

    [
       {
          "roll_number":1,
          "st_name":"Adam",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       }
    ]
    

    Example: Deleting Multiple Rows of Data

    If you want to remove more than one row at a time, you can use the remove() method as follows −

    from tinydb import TinyDB, Query
    student = Query()
    db.remove(student.roll_number > 2)
    

    It will return the IDs of the removed object:

    [3,4]
    

    Use the all() method to see the updated database.

    db.all()
    

    It will display the data from the updated database −

    [
       {
          "roll_number":1,
          "st_name":"Adam",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       }
    ]
    

    Example: Deleting the Entire Data

    If you want to remove all the data from a database, you can use the truncate() method as follows −

    db.truncate()
    

    Next, use the all() method to see the updated database.

    db.all()
    

    It will show an empty database as the output

    []
    

    TinyDB – Querying

    TinyDB has a rich set of queries. We have ways to construct queries: the first way resembles the syntax of ORM tools and the second is the traditional way of using the ”Where” clause.

    In this chapter, let”s understand these two ways of constructing a query in a TinyDB database.

    The First Method: Importing a Query

    The first method resembles the syntax of ORM tools in which first we need to import the query in the command prompt. After importing, we can use the query object to operate the TinyDB database. The syntax is given below −

    from tinydb import Query
    student = Query()
    

    Here, ”student” is the name of our database. For the examples, we will be using the following student database.

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    Example

    Following is the query to retereive the data from the student database where the roll_no of the students are less than 3 −

    >>> db.search(Query().roll_number < 3)
    

    Or,

    >>> student = Query()
    >>> db.search(student.roll_number < 3)
    

    The above search query will produce the following result −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       }
    ]
    

    Sometimes the file name is not a valid Python identifier. In that case, we would not be able to access that field. For such cases, we need to switch to dict access notation as follows −

    student = Query();
    
    # Invalid Python syntax
    db.search(student.security-code == ''ABCD'')
    
    # Use the following dict access notation
    db.search(student[''security-code''] == ''ABCD'')
    

    The Second Method: Using the “where” Clause

    The second way is the traditional way of constructing queries that uses the “where” clause. The syntax is given below −

    from tinydb import where
    db.search(where(''field'') == ''value'')
    

    Example

    TinyDB “where” clause for the subject field −

    db.search(where(''subject'') == ''MySQL'')
    

    The above query will produce the following output

    [{
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
    }]
    

    TinyDB – Searching

    TinyDB provides the search() method to help you search any data from a document. Along with the query() object, the search() method can be used to find the data in a JSON file. We have various ways in which we can use the search() method on a TinyDB database.

    Method 1: TinyDB search() with Existence of a Field

    We can search the data from a database based on the existence of a field. Let”s understand it with an example. For this and other examples, we will be using the following student database.

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    Example

    The search query based on the existence of a field is as follows −

    from tinydb import Query
    student = Query()
    db.search(student.address.exists())
    

    The above query will retrieve the following data from the student file −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    Method 2: TinyDB search() with Regular Expression

    We can search for a particular data from a database using regular expression (Regex). Let”s understand how it works with a couple of examples.

    Example 1

    Full item search matching the Regular Expression −

    from tinydb import Query
    student = Query()
    db.search(student.st_name.matches(''[aZ]*''))
    

    This query will produce the following output

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    Example-2

    Case-sensitive search with Regular Expression −

    from tinydb import Query
    import re
    student = Query()
    db.search(student.st_name.matches(''lakan'', flags=re.IGNORECASE))
    

    It wil produce the following output

    [{
       ''roll_number'': 4,
       ''st_name'': ''lakan'',
       ''mark'': 200,
       ''subject'': ''MySQL'',
       ''address'': ''mumbai''
    }]
    

    Example-3

    Any part of the item matching with Regular Expression −

    from tinydb import Query
    student = Query()
    db.search(student.st_name.search(''r+''))
    

    This query will produce the following output

    [{
       ''roll_number'': 5,
       ''st_name'': ''karan'',
       ''mark'': 275,
       ''subject'': ''TinyDB'',
       ''address'': ''benglore''
    }]
    

    Method 3: TinyDB search() using a Substring

    We can also use a substring while searching for a particular data from a TinyDB database. Let”s understand how it works with a couple of examples −

    Example-1

    Take a look at this query; it will fetch the all the rows where the “address” field is “delhi”.

    from tinydb import Query
    student = Query()
    db.search(student[''address''] == ''delhi'')
    

    It will produce the following output

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       }
    ]
    

    Example-2

    In this query, we have used a slightly different syntax for the search() method.

    from tinydb import Query
    student = Query()
    db.search(student.address.search(''mumbai''))
    

    It will fetch all the rows where the “address” field is “mumbai”.

    [{
       ''roll_number'': 4,
       ''st_name'': ''lakan'',
       ''mark'': 200,
       ''subject'': ''MySQL'',
       ''address'': ''mumbai''
    }]
    

    TinyDB – The where Clause

    TinyDB provides the “where” clause that you can use while searching for a particular data. The “where” clause helps by filtering the unwanted data out. With the help of the “where” clause, you can access specific data quickly.

    Before using the ”where” clause, we need to first import it. The syntax of “where” clause is given below −

    from tinydb import where
    db.search(where(''field'') == ''value'')
    

    Let”s understand the use of ”where” clause with the help of a couple of examples.

    The Student Database

    For the examples, we will use the following student database.

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    Example 1

    Let”s use the “where” clause for the subject field −

    db.search(where(''subject'') == ''MySQL'')
    

    This query will fetch all the rows where the “subject” field is “MySQL”.

    [{
       ''roll_number'': 4,
       ''st_name'': ''lakan'',
       ''mark'': 200,
       ''subject'': ''MySQL'',
       ''address'': ''mumbai''
    }]
    

    Example 2

    Let”s see another use of the “where” clause with the “not equal to” condition −

    db.search(where(''mark'') != 275)
    

    This query will fetch all the rows where the “mark” field is not equal to “275” −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       }
    ]
    

    TinyDB – The exists() Query

    TinyDB provides an advanced query called exists() that checks the existence of data in a JSON file. The exists() query actually tests the availability of a subfield data from a JSON file. The exists() query works on the basis of a Boolean condition. If the subfield exists (i.e., BOOLEAN TRUE), it will fetch the data accordingly from the JSON file, otherwise it will return a blank value.

    Syntax

    The syntax of TinyDB exists() is as follows −

    db.search(Query().field.exists())
    

    Here, field represents the part of data that we want to access. Query() is the object created from the JSON table student.

    We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s use the TinyDB exists() query for the field named ”subject” −

    db.search(student.subject.exists())
    

    This query will fetch all the rows because all the rows have the “subject” field −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":" TinyDB ",
          "address":"benglore"
       }
    ]
    

    Example 2

    Now let”s use the exists() query for the ”address” field −

    db.search(student.address.exists())
    

    It will fetch the following rows −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":" TinyDB ",
          "address":"benglore"
       }
    ]
    

    Example 3

    Now, let”s try the exists() query for a field that is not available −

    db.search(student.city.exists())
    

    Since none of the rows in the given table has a field called “city”, the above exists() query will return a blank value −

    []
    

    TinyDB – The matches() Query

    The matches() query matches the data from a JSON file with a given condition (in the form of a regular expression) and returns the results accordingly. It will return a blank value if the condition does not match with the data in the file.

    Syntax

    The syntax of TinyDB matches() is as follows −

    db.search(Query().field.matches(regular expression))
    

    Here, field represents the part of data that we want to access. Query() is the object created of our JSON table named student.

    Let”s understand how it works with the help of a couple of examples. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s see how we can use matches() for full item search.

    from tinydb import Query
    student = Query()
    db.search(student.st_name.matches(''[aZ]*''))
    

    This query will fetch all the rows −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    Example 2

    Let”s see how we can use matches() for case-sensitive search.

    from tinydb import Query
    import re
    student = Query()
    db.search(student.st_name.matches(''ram'', flags=re.IGNORECASE))
    

    This query will fetch the rows where the student name matches the string “ram”. Observe that we have used a flag to ignore the case while matching the strings.

    [{
       ''roll_number'': 2,
       ''st_name'': ''Ram'',
       ''mark'': [250, 280],
       ''subject'': [''TinyDB'', ''MySQL''],
       ''address'': ''delhi''
    }]
    

    Example 3

    Let”s see how we can use matches() for a particular item.

    student = Query()
    db.search(student.address.matches(''keral''))
    

    This query will fetch the rows where the address matches the string “keral”.

    [{''roll_number'': 3, ''st_name'': ''kevin'', ''mark'': [180, 200], ''subject'':
    [''oracle'', ''sql''], ''address'': ''keral''}]
    

    Example 4

    Let”s see what matches() would return when it does not find a particular item −

    student = Query()
    db.search(student.address.matches(''Ratlam''))
    

    There are no rows where the “address” field matches the string “Ratlam”, hence it will return a blank value −

    []
    

    TinyDB – The test() Query

    The test() query will test if the given arguments match with the data in a table. If it matches with the data, it will return the matched data, otherwise it will return blank. First of all, we need to define a test function and its arguments and then it will search the item in a given database.

    Syntax

    The syntax of TinyDB test() is as follows −

    db.search(Query().field.test(function or condition, *arguments))
    

    Here, field represents the part of data that we want to access. Query() is the object created of our JSON table named student.

    We can create a custom test function as follows −

    object = lambda t: t == ''value''
    

    Here the lamba keyword is important to create the custom test function.

    Let”s understand how it works with the help of a couple of examples. We will use the same student database that we have used in all the previous chapters.

    Example 1

    We will first create a test function and then use it in our student table −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    objects = lambda t: t == [250, 280]
    db.search(Query().mark.test(objects))
    

    It will fetch the rows where the “mark” field has the values [250, 280] −

    [{''roll_number'': 2, ''st_name'': ''Ram'', ''mark'': [250, 280], ''subject'':
    [''TinyDB'', ''MySQL''], ''address'': ''delhi''}]
    

    Example 2

    In this example, we will use the “subject” field in the test function −

    student = Query()
    db = TinyDB(''student.json'')
    objects = lambda t: t == ''TinyDB''
    db.search(student.subject.test(objects))
    

    This query will fetch all the rows where the “subject” field has the value “TinyDB” −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    TinyDB – The any() Query

    For searching the fields containing a list, TinyDB provides a method called any(). This method matches at least one given value from the database. It finds either an entire list or a minimum one value as per the query provided.

    Syntax

    The syntax of TinyDB any() is as follows −

    db.search(Query().field.any(query|list)
    

    Here, field represents the part of data that we want to access. Query() is the object created of our JSON table named student.

    • If we will provide query as the argument of any() method, it will match all the documents where at least one document in the list field match the given query.

    • On the other hand, if we will provide list as the argument of any() method, it will match all the documents where at least one document in the list field is present in the given list.

    Let”s understand how it works with the help of a couple of examples. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s see how we can find the fields from our student table where subject is either TinyDB, or MySQL, or SQL or combination of any two or three −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.search(Query().subject.any([''TinyDB'', ''MySQL'', ''oracle'']))
    

    The above query will fetch all the rows where the “subject” field contains any of the following values: “TinyDB”, “MySQL”, or “oracle” −

    [
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       }
    ]
    

    Example 2

    Let”s see how the any() method reacts when it doesn”t match anything from the given list −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.search(Query().subject.any([''Oracle'']))
    

    This query will return a blank value because there are no rows with its “subject” as “Oracle”.

    []
    

    Example 3

    Observe that it is case-sensitive. The “subject” field does not have “Oracle“, but it does have “oracle“. Try the following query −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.search(Query().subject.any([''oracle'']))
    

    It will fetch the following row −

    [{
       ''roll_number'': 3,
       ''st_name'': ''kevin'',
       ''mark'': [180, 200],
       ''subject'': [''oracle'', ''sql''],
       ''address'': ''keral''
    }]
    

    As it is case-sensitive, it returned a blank value in the previous example because there are no rows with its “subject” as “Oracle”.

    TinyDB – The all() Query

    TinyDB provides a method called all() that finds an entire list of values as per the query provided. Let”s take an example and find out how it works.

    Syntax

    The syntax of TinyDB all() is as follows −

    db.search(Query().field.all(query|list)
    

    Here, field represents the part of data that we want to access. Query() is the object created of our JSON table named student.

    • If we will provide a query as the argument of all() method, it will match all the documents where all documents in the list field match the given query.

    • On the other hand, if we will provide a list as the argument of all() method, it will match all the documents where all documents in the list field are present in the given list.

    Let”s understand how it works with the help of a couple of examples. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s see how we can find the fields from our student table where the subjects are both TinyDB, and MySQL −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.search(Query().subject.all([''TinyDB'', ''MySQL'']))
    

    This query will fetch the following row −

    [{
       ''roll_number'': 2,
       ''st_name'': ''Ram'',
       ''mark'': [250, 280],
       ''subject'': [''TinyDB'', ''MySQL''],
       ''address'': ''delhi''
    }]
    

    Example 2

    Let”s see how we can use all() to get the entire data from our database −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.all()
    

    It will fetch all the rows from the linked database −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    TinyDB – The one_of() Query

    For matching the subfield data, TinyDB provides a method called one_of(). This method searches a single category and gets at least one similar value. It will match if the field is contained in the provided list.

    Syntax

    The syntax of TinyDB one_of() is as follows −

    db.search(Query().field.one_of(list)
    

    Here, field represents the part of data that we want to access. Query() is the object created of our JSON table named student. It will fetch either single or multiple values of one category.

    Let”s understand how it works with the help of a couple examples. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s see how we can find the fields from our student table where address is either “delhi” or “pune” −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.search(Query().address.one_of([''delhi'', ''pune'']))
    

    It will fetch all the rows where the “address” field contains either “delhi” or “pune”.

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       }
    ]
    

    Example 2

    Let”s see another example with ”subject” field −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.search(Query().subject.one_of([''TinyDB'', ''MySQL'']))
    

    It will fetch all the rows where the “subject” field contains either “TinyDB” or “MySQL”.

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":4,
          "st_name":"lakhan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    TinyDB – Logical Negate

    Logical Negate works as an inverse logical gate. It will match the documents that don”t match the given query. In simple words, it will display the opposite meaning of the given command.

    Syntax

    The syntax of TinyDB Logical Negate is as follows −

    db.search(~(Query().field)
    

    Here, field represents the part of data that we want to access. Query() is the object created of our JSON table named student. It will fetch the data that represents the opposite meaning of the given command.

    Let”s take a couple of examples and see how it works. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s see how we can find the fields from our student table where the student name is not ”elen” −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.search(~(Query().st_name == ''elen''))
    

    The above query will fetch all the rows where the student name is not “elen”.

    [
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    Example 2

    Let”s see how we can avoid a particular address using logical negate −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.search(~(student.address.one_of([''keral'', ''delhi''])))
    

    This query will fetch all the rows where the “address” field does not have either “keral” or “delhi”.

    [
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    TinyDB – Logical AND

    The “Logical AND” operator combines multiple conditions and evaluates to True if all the conditions are met. TinyDB Logical AND operates on two queries of a database. If both the queries are True, TinyDB will fetch the required data. On the other hand, if any one of the queries is False, it will return a blank.

    Syntax

    The syntax of TinyDB Logical AND is as follows −

    db.search((Query().(query1) & (Query().(query2)
    

    Here, field represents the part of data that we want to access. Query() is the object created of our JSON table named student. It will fetch the data if both the conditions met, otherwise it will return a blank.

    Let”s take a couple examples and see how Logial AND works. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s see what our TinyDB Student database returns when we apply Logical AND on “st_name=lakhan” and “subject=MYSQL” field −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.search ((Query().st_name == ''lakhan'') & (Query().subject == ''MySQL''))
    

    This query will fetch only those rows where the student name is “lakhan” and the “subject” is “MySQL”.

    [{
       ''roll_number'': 4,
       ''st_name'': ''lakhan'',
       ''mark'': 200,
       ''subject'': ''MySQL'',
       ''address'': ''mumbai''
    }]
    

    Example 2

    In this example, let”s apply Logical AND on the “subject” and “roll_number” fields −

    from tinydb import TinyDB, Query
    student = Query()
    db = TinyDB(''student.json'')
    db.search((student.subject.search(''M'')) & (student.roll_number < 5))
    

    This query will fetch all the rows where the roll_number is less than “4” and “subject” starts with the letter “M”.

    [{
       ''roll_number'': 4,
       ''st_name'': ''lakhan'',
       ''mark'': 200,
       ''subject'': ''MySQL'',
       ''address'': ''mumbai''
    }]
    

    TinyDB – Logical OR

    The “Logical OR” operator combines multiple conditions and evaluates to True only if either of the condition is met. TinyDB Logical OR operates on two queries of a database. If any one of the queries is True, TinyDB will fetch the required data. On the other hand, if both the queries are False, it will return a blank.

    Syntax

    The syntax of TinyDB Logical OR is as follows −

    db.search((Query().(query1) | (Query().(query2)
    

    Here, field represents the part of data that we want to access. Query() is the object created of our JSON table named student. It will fetch the data if any one of the conditions is met, otherwise it will return a blank.

    Let”s take a couple of examples and see how it works. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s see what our TinyDB Student database returns when we apply Logical OR on the “st_name” and “subject” fields and check the following conditions: “st_name=lakhan” and “subject=TinyDB” −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.search ((Query().st_name == ''lakan'') | (Query().subject == ''TinyDB''))
    

    This query will fetch the following rows −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":4,
          "st_name":"lakhan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    Example 2

    In this example, let”s apply Logical OR on the “subject” and “roll_number” fields −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.search((student.subject.search(''M'')) | (student.roll_number < 5))
    

    This query will fetch all the rows where the “subject” field starts with the letter “M” or the “roll_number” is less than “5”.

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakhan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       }
    ]
    

    TinyDB – Handling Data Query

    TinyDB – Storing Multiple Data

    We have already discussed how you can use the ”insert” query to store data in a database. On a similar note, you can use the ”insert_multiple” query to store multiple data items simultaneously. Here is the syntax of ”insert_multiple” query in TinyDB:

    db.insert_multiple ([
       { key1 : value1, key2 : value2, ..., keyN : valueN},
       { key1 : value1, key2 : value2, ..., keyN : valueN }
    ])
    

    Let”s take a couple of examples to demonstrate how the “insert_multiple” query works. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s see how we can insert two records of students in our ”student” table using the insert_multiple query −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.insert_multiple([
       {
          "roll_number":6,
          "st_name":"Siya",
          "mark":240,
          "subject":"NoSQL",
          "address":"pune"
       },
       {
          "roll_number":7,
          "st_name":"Adam",
          "mark":210,
          "subject":"oracle",
          "address":"Keral"
       }
    ])
    

    It will display the document IDs of the newly saved records −

    [6, 7]
    

    Let”s check whether the new records are saved in the database or not? Use the all() method, as shown below −

    db.all()
    

    It will show all the records stored in the given table −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       },
       {
          "roll_number":6,
          "st_name":"Siya",
          "mark":240,
          "subject":"NoSQL",
          "address":"pune"
       },
       {
          "roll_number":7,
          "st_name":"Adam",
          "mark":210,
          "subject":"oracle",
          "address":"Keral"
       }
    ]
    

    You can see the two new records of students have been saved in the database.

    Example 2

    Let”s see how we can use insert_multiple with a for loop to insert multiple values simultaneously in a table. Use the following code −

    db.insert_multiple({''roll_number'': 10, ''numbers'': r} for r in range(3))
    

    It will return the document IDs of the newly saved records −

    [8, 9, 10]
    

    Again, use the all() method to verify whether the new records have been saved in the database or not?

    db.all()
    

    It will fetch all the records stored in the given student table −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       },
       {
          "roll_number":6,
          "st_name":"Siya",
          "mark":240,
          "subject":"NoSQL",
          "address":"pune"
       },
       {
          "roll_number":7,
          "st_name":"Adam",
          "mark":210,
          "subject":"oracle",
          "address":"Keral"
       },
       {
          "roll_number":10,
          "numbers":0
       },
       {
          "roll_number":10,
          "numbers":1
       },
       {
          "roll_number":10,
          "numbers":2
       }
    ]
    

    Notice the last three rows. We have used the insert_multiple method with a for loop to insert three new entries.

    TinyDB – Modifying the Data

    We have already discussed the update query with the help of which we can modify the values as well as handle the data in our database. But the update query such as db.update(fields, query) allows us to update a document by adding or overwriting its values.

    But sometimes, we would like to remove one field or need to increment its value. In such cases, we can pass a function instead of fields. We can use the following operations with the update query −

    The Increment Query

    The increment query, as its name implies, is used to increment the value of a key in the database. The syntax of increment query is as follows −

    from tinydb.operations import increment
    db.update(increment(''key''))
    

    The Add Query

    The add query is used to add value to the value of a key. It works for the strings as well. The syntax of add query is as follows −

    from tinydb.operations import add
    db.update(add(key, value))
    

    The Set Query

    This query is used to set the key to the value of the data. The syntax of set query is as follows −

    from tinydb.operations import set
    db.update(set(key, value))
    

    The Decrement Query

    The decrement query is used to decrement the value of a key. The syntax of decrement query is as follows −

    from tinydb.operations import decrement
    db.update(decrement(key))
    

    The Subtract Query

    The subtarct query is used to subtract value from the value of a key. The syntax of subtract query is as follows −

    from tinydb.operations import subtract
    db.update(subtract(key, value))
    

    The Delete Query

    The delete query is used to delete a key from a document. The syntax of delete query is as follows −

    from tinydb.operations import delete
    db.update(delete(key))
    

    Let”s take a couple of examples to demonstrate how you can use these operations along with the update query. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s see how we can increment the marks of a student in our student table −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    from tinydb.operations import increment
    db.update(increment(''mark''), Query().mark == 275)
    

    It will produce the following output

    [5]
    

    The above output shows that it has updated the record whose document ID is 5.

    Example 2

    Let”s see how we can add 5 marks to the marks of a student in our student table −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    from tinydb.operations import add
    db.update(add(''mark'', 5), Query().mark == 200)
    

    It will produce the following output

    [4]
    

    The above output shows that it has updated the record whose document ID is 4.

    Example 3

    Let”s see how we can set the marks to 259 where the marks of a student are 250 in our student table −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    from tinydb.operations import add
    db.update(add(''mark'', 259), Query().mark == 250)
    

    It will produce the following output

    [1]
    

    The above output shows that it has updated the record whose document ID is 1.

    Example 4

    Let”s see how we can decrement the marks of a student in our student table −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    from tinydb.operations import decrement
    db.update(decrement(''mark''), Query().mark == 205)
    

    It will produce the following output

    [4]
    

    The above output shows that it has updated the record whose document ID is 4.

    Example 5

    Let”s see how we can subtract 5 marks to the marks of a student in our student table −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    from tinydb.operations import add
    db.update(add(''mark'', 5), Query().mark == 204)
    

    It will produce the following output

    [4]
    

    The above output shows that it has updated the record whose document ID is 4.

    Example 6

    Let”s see how we can subtract 5 marks to the marks of a student in our student table −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    from tinydb.operations import delete
    db.update(delete(''mark''), Query().mark == 209)
    

    It will produce the following output

    [4]
    

    The above output shows that it has updated the record whose document ID is 4. It will delete the mark field from the database where the value is 209.

    Example 7

    Let”s see how we can update multiple values in a table with a single query −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    from tinydb import where
    db.update_multiple([
       ({''st_name'':''Eliana''}, where (''roll_number'')==1),
       ({''mark'':20}, where (''roll_number'') ==2)
    ])
    

    It will produce the following output

    [1,2]
    

    The above output shows that it has updated two records whose document IDs are 1 and 2.

    TinyDB – Upserting Data

    We discussed the update and insert queries, but sometimes, we a need a mix of both update and insert. In such cases, TinyDB provides a unique upsert query. This query helps us to insert and update data at a time as per the condition. It works in two ways −

    • If data is available, then it chooses the update operation.

    • If data is not available, then it chooses the insert operation.

    Syntax

    The syntax of upsert query is as follows −

    db.upsert({ ''key'' : ''value'', ''logged - in'' : True}, regular expression)
    

    Let”s take a couple of examples to demonstrate how you can use this upsert query in TinyDB. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s see how we can use the upsert query to change the address of a student to “surat”, whose roll numbe is 2. In this case, we we have a matching user, hence it will update with the address to have logged-in set to True −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.upsert({''address'':''Surat''}, Query().roll_number==2)
    

    It will produce the following output, which means record number “2” got updated.

    [2]
    

    Use the following code to verify whether record number “2” got updated or not −

    db.get(doc_id=2)
    

    It will show the updated data −

    {
       ''roll_number'': 2,
       ''st_name'': ''Ram'',
       ''mark'': [250, 280],
       ''subject'': [''TinyDB'', ''MySQL''],
       ''address'': ''Surat''
    }
    

    Example 2

    Let”s see how we can use the upsert query for unavailable data in our table −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.upsert({''E-mail'':''ram@gmail.com'',''logged-in'': True},
    Query().roll_number==2)
    

    It will show the following output, which means the document with the ID “2” got updated.

    [2]
    

    Use the following code to verify the updated values −

    db.get(doc_id=2)
    

    It will produce the following output −

    {
       "roll_number":2,
       "st_name":"Ram",
       "mark":[
          250,
          280
       ],
       "subject":[
          "TinyDB",
          "MySQL"
       ],
       "address":"Surat",
       "logged-in":true,
       "E-mail":"ram@gmail.com"
    }
    

    Notice that we used the upsert query to create a new key (E-mail) which was non-existent and supplied it with the value “ram@gmail.com“.

    TinyDB – Retrieving Data

    After creating a database, we need to frequently retrieve the data from that database. Following are the ways by which we can reterive the data from a database −

    The len() Query

    With the help of this query, we can get the number of documents in a database. Its syntax is as follows −

    len(db)
    

    The get Query

    The get query is used to reterive specific documents matching a query. Its syntax is as follows −

    db.get(query)
    

    The contains Query

    The contains query is used to check whether the database contains a matching value or not. Its syntax is as follows −

    db.contains(query)
    

    The count Query

    The count query is used to retrieve the number of matching documents from a database. Its syntax is as follows −

    db.count(query)
    

    Let”s take a few examples to understand how these queries work in TinyDB. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s see how we can use the len() query to get the number of documents in our database −

    from tinydb import TinyDB
    db = TinyDB(''student.json'')
    print ("Number of documents in student db: ", len(db))
    

    It will show the number of documents present in the specified database −

    Number of documents in student db: 5
    

    Example 2

    Let”s see how we can use the get() query to get a specific document from our database −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.get(Query().address == ''delhi'')
    

    This query will fetch the row where the “address” field has the value “delhi”.

    {
       ''roll_number'': 1,
       ''st_name'': ''elen'',
       ''mark'': 250,
       ''subject'': ''TinyDB'',
       ''address'': ''delhi''
    }
    

    Example 3

    Let”s see how we can use the contains() query to verify if our database contains a specific value −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    db.contains(Query().address == ''delhi'')
    

    The contains() query returns a Boolean value, based on the existence of the specified value in the given database. In this case, it will return “True” because our database does have a “address” key with the value “delhi”.

    True
    

    Example 4

    Let”s see how we can use the count() query to get the number of documents for which a given condition is True −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    print (db.count(Query().subject == ''NoSQL''))
    

    It will return the following output

    3
    

    It means there are 3 documents in the database where the “subject” key has the value “NoSQL”.

    TinyDB – Document ID

    TinyDB uses document ID, represented by doc_id, to access as well as modify the value of documents in a database. Here we will see how we can use this document_id for various operations.

    Display Data using Document ID

    We can use doc_id in get() method to display the data from a database. Its syntax is as follows −

    db.get(doc_id = value)
    

    Check for a Document in a Database

    We can use doc_id in contains() method to check if a document is present in a database or not. Its syntax is given below −

    db.contains(doc_id = value)
    

    Update All Documents

    We can use doc_id in update() method to update all the documents in a database with the given document IDs. Here is its syntax

    db.update({key : value}, doc_ids = […])
    

    Remove a Document

    We can use doc_id in remove() method to remove a specific document or all the documents in a database with the given document IDs. Its syntax is given below −

    db.remove(doc_ids = […])
    

    Let”s take a few examples to demonstrate how you can use doc_id in TinyDB with these methods. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Let”s see how we can use doc_id to get the data of a specific document from a database −

    from tinydb import TinyDB
    db = TinyDB(''student.json'')
    db.get(doc_id = 5)
    

    It will fetch the data from the document with the doc_id “5”.

    {
       ''roll_number'': 5,
       ''st_name'': ''karan'',
       ''mark'': 275,
       ''subject'': ''oracle'',
       ''address'': ''benglore''
    }
    

    Example 2

    Let”s see how we can use doc_id to check if the database contains a document with a specific ID −

    from tinydb import TinyDB
    db = TinyDB(''student.json'')
    db.contains(doc_id = 15)
    

    Based on the availability of the document, it will return either True or False. In this case, our database does not have a document with the doc_id “15”. Hence, it returns False.

    False
    

    Example 3

    Let”s see how we can use doc_id to update the documents of our database −

    from tinydb import TinyDB
    db = TinyDB(''student.json'')
    db.update({''mark'':''280''}, doc_ids = [4])
    

    Here, we updated the “marks” field of the document with the doc_id “4”. To check the updated data, use the following query −

    print(db.get(doc_id=4))
    

    It will display the updated data of the document with the doc_id “4” −

    {
       ''roll_number'': 4,
       ''st_name'': ''lakan'',
       ''mark'': ''280'',
       ''subject'': ''MySQL'',
       ''address'': ''mumbai''
    }
    

    Example 4

    Let”s see how we can use doc_id to remove specific documents from our database −

    from tinydb import TinyDB
    db = TinyDB(''student.json'')
    db.remove(doc_ids = [3,4])
    

    Here, we removed two documents with doc_ids “3” and “4”. To verify, use the following get() queries −

    db.get(doc_id=3)
    db.get(doc_id=4)
    

    It will show the following output −

    None
    None
    

    It means that we have successfully removed the documents with doc_ids “3” and “4”.

    TinyDB – Tables

    In TinyDB, we can work with multiple tables. These tables have the same properties as the TinyDB class. Let”s see how we can create tables in TinyDB and apply various operations on them −

    Creating Tables

    It’s very easy to create a table in TinyDB. Here”s its syntax −

    table_object = db.table(''table name'')
    

    Inserting Values in a Table

    To insert data in a specific table, use the following syntax −

    table_object.insert({ ''key'' : value })
    

    Retreiving Values from a Table

    To retrieve values from a table, use the following query −

    table_object.all()
    

    Deleting a Table from a Database

    To delete a table from a database, use the drop_table() query. Here is its syntax

    db.drop_table(''table name'')
    

    Delete Multiple Tables from a Database

    To delete multiple tables from a database, use the following query −

    db.drop_tables()
    

    Let”s understand how to use these queries with the help of a few examples. We will use the same student database that we have used in all the previous chapters.

    Example 1

    Use the following code to create a new table called Student_Detail

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    table_object = db.table(''Student_Detail'')
    

    Example 2

    Next, let”s insert values in this new table Student_Detail

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    table_object = db.table(''Student_Detail'')
    table_object.insert({
       ''roll_number'': 1,
       ''st_name'': ''elen'',
       ''mark'': 250,
       ''subject'': ''TinyDB'',
       ''address'': ''delhi''
    })
    

    It will return the doc_id of the record inserted in the table.

    [1]
    

    To verify, use the following code −

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    table_object = db.table(''Student_Detail'')
    table_object.all()
    

    It will show data contained in the Student_Detail table −

    {''roll_number'': 1, ''st_name'': ''elen'', ''mark'': 250, ''subject'': ''TinyDB'', ''address'': ''delhi''}
    

    Example 3

    To see all the tables present in the database, use the following query −

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    print(db.tables())
    

    There are two tables inside “student.json”. It will show the names of these two tables −

    {''Student_Detail'', ''_default''}
    

    Example 4

    Let”s see how we can reterive all the values from a table −

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    table_object = db.table("Student_Detail")
    print(table_object.all())
    

    It will show the following output

    [{
       ''roll_number'': 1,
       ''st_name'': ''elen'',
       ''mark'': 250,
       ''subject'': ''TinyDB'',
       ''address'': ''delhi''
    }]
    

    Example 5

    Let”s see how we can remove a table from a database −

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    db.drop_table(''Student_Detail'')
    

    It will remove the “Student_Detail” table from the database. To remove all the tables from a database, use the “drop_tables()” query −

    db.drop_tables()
    

    It will remove all the tables from the database.

    TinyDB – Default Table

    TinyDB provides a default table in which it automatically saves and modifies the data. We can also set a table as the default table. The basic queries, methods, and operations will work on that default table. In this chapter, let”s see how we can see the tables in a database and how we can set a table of our choice as the default table −

    Showing the Tables in a Database

    To get the list of all the tables in a database, use the following code −

    from tinydb import TinyDB, Query
    db = TinyDB("student.json")
    db.tables()
    

    It will produce the following output: We have two tables inside “student.json”, hence it will show the names of these two tables −

    {''Student_Detail'', ''_default''}
    

    The output shows that we have two tables in our database, one is “Student_Detail” and the other “_default”.

    Displaying the Values of the Default Table

    If you use the all() query, it will show the contents of the default table −

    from tinydb import TinyDB
    db = TinyDB("student.json")
    db.all()
    

    To show the contents of the “Student_Detail” table, use the following query −

    from tinydb import TinyDB
    db = TinyDB("student.json")
    print(db.table("Student_Detail").all())
    

    It will show the contents of the “Student_Detail” table −

    [{
       ''roll_number'': 1,
       ''st_name'': ''elen'',
       ''mark'': 250,
       ''subject'': ''TinyDB'',
       ''address'': ''delhi''
    }]
    

    Setting a Default Table

    You can set a table of your choice as the default table. For that, you need to use the following code −

    from tinydb import TinyDB
    db = TinyDB("student.json")
    db.default_table_name = "Student_Detail"
    

    It will set the “Student_Detail” table as the default table for our database.

    TinyDB – Caching Query

    Catching query is an advanced feature of TinyDB with the help of which it caches the query result for performance optimization. In this way, when we run the same query again, TinyDB doesn”t need to read the data from the storage. We can pass the cache_size to the table function to optimize the query cache size.

    Syntax

    The syntax of TinyDB query caching is shown below −

    table = db.table(''table_name'', cache_size=value)
    

    Example

    TinyDB creates cache size memory in given table.

    from tinydb import TinyDB
    db = TinyDB(''student.json'')
    objects = db.table(''Student_Detail'', cache_size = 50)
    objects.all()
    

    It will produce the following output. Observe that cache size does not affect the table values.

    [{
       ''roll_number'': 1,
       ''st_name'': ''elen'',
       ''mark'': 250,
       ''subject'': ''TinyDB'',
       ''address'': ''delhi''
    }]
    

    We can set unlimited cache size by putting “cache_size = None”.

    objects = db.table(''Student_Detail'', cache_size = None)
    

    We can also disable the cache size by putting “cache_size = 0”.

    objects = db.table(''Student_Detail'', cache_size = 0)
    

    To clear the cache size, use the following query −

    db.clear_cache()
    

    TinyDB – Storage Types

    TinyDB has two types of storage: JSON and in-memory. TinyDB, by default, stores the data in JSON files. While creating a database, you need to specify the path where to store the JSON file on your computer.

    Storing Data in a JSON File

    First, let”s see how we can use a JSON file to store the data −

    from tinydb import TinyDB, where
    db = TinyDB(''path/to/file_name.json'')
    

    Example 1

    In this example, we are showing how you can insert multiple documents into a JSON file −

    from tinydb import TinyDB
    db = TinyDB(''storage.json'')
    db.insert_multiple([
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakhan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"oracle",
          "address":"benglore"
       }
    ])
    

    Here, we inserted 5 documents inside “storage.json”. To verify the records, use the following query −

    db.all()
    

    It will show the contents of “storage.json” file −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakhan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"oracle",
          "address":"benglore"
       }
    ]
    

    Using in-memory to Store Data

    Now, let”s see how we can use “in-memory” to store the data −

    from tinydb import TinyDB
    from tinydb.storages import MemoryStorage
    object = TinyDB(storage = MemoryStorage)
    TinyDB.DEFAULT_STORAGE = MemoryStorage
    

    Example 2

    The following example shows how you can insert multiple documents in default storage memory −

    from tinydb import TinyDB
    from tinydb.storages import MemoryStorage
    object = TinyDB(storage = MemoryStorage)
    TinyDB.DEFAULT_STORAGE = MemoryStorage
    object.insert_multiple([
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"oracle",
          "address":"benglore"
       }
    ])
    

    To verify whether the documents have been inserted or not, use the following query −

    object.all()
    

    The following output shows the inserted data −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"oracle",
          "address":"benglore"
       }
    ]
    

    TinyDB – Middleware

    TinyDB middleware helps us to customize database storage behavior by wrapping around the existing storage. This middleware improves the performance of the database.

    Caching Middleware

    This middleware, as its name implies, improves the speed of a database by reducing the disk I/O. The working of CachingMiddleware is as follows −

    • First, it catches all the read operations.

    • Then it writes the data to the disk after a configured number of write operations.

    Syntax

    The syntax to use CachingMiddleware is as follows −

    from tinydb.storages import JSONStorage
    from tinydb.middlewares import CachingMiddleware
    db = TinyDB(''middleware.json'', storage = CachingMiddleware(JSONStorage))
    db.close()
    

    Example

    The following example shows how you can perform a basic middleware procedure in a database.

    from tinydb import TinyDB
    from tinydb.storages import JSONStorage
    from tinydb.middlewares import CachingMiddleware
    object = TinyDB(''storage.json'', storage=CachingMiddleware(JSONStorage))
    object.all()
    

    Output

    It will produce the following output −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"oracle",
          "address":"benglore"
       }
    ]
    

    Close the database to make sure that all the data is safely written.

    db.close()
    

    TinyDB – Extend TinyDB

    It is possible to extend TinyDB and modify its behaviour. There are four ways to do so −

    • Custom middleware

    • Custom storages

    • Hooks and overrides

    • Subclassing TinyDB and table

    In this chapter, let”s understand each of these methods in detail.

    Custom Middleware

    Sometimes the user does not want to write a new storage module. In such cases, the user can modify the behaviour of an existing storage module. Let”s see an example in which we will build a custom middleware filtering out the empty items −

    First, let”s see the data that will go through the custom middleware −

    {
       ''_default'': {
       1: {''key1'': ''value1''},
       2: {''key2'': ''value2''},
       ……………,
       N: {''keyN'': ''valueN''}
    },
    
    

    Now, let”s see how we can implement the custom middleware −

    class RemoveEmptyItemsMiddleware(Middleware):
    def __init__(self, storage_cls):
       super(self).__init__(storage_cls)
       def read(self):
          data = self.storage.read()
          for _default in data:
             st_name = data
          for doc_id in table:
             item = st_name
             if item == {}:
                del st_name
             return data
       def close(self):
          self.storage.close()
    

    Custom Storage

    As discussed earlier, TinyDB comes with two types of storages: in-memory and JSON file storage. Along with that, TinyDB also provides an option to add our own custom storage. In the following example, let”s see how we can add a YAML storage using PyYAML −

    import yaml
    class YAMLStorage(Storage):
    def __init__(self, db.json):
       self. db.json = db.json
    

    To read the file −

    def read(self):
       with open(self.db.json) as handle:
       try:
          info = yaml.safe_load(handle.read())
          return info
    
       except yaml.YAMLError:
          return None
    

    To write the file −

    def write(self, info):
       with open(self.db.json, ''w+'') as handle:
          yaml.dump(info, handle)
    

    To close the file −

    def close(self):
       pass
    

    Hooks and Overrides

    Sometimes, both custom storage and custom middleware cannot work in the way you want. In such cases, user can use predefined hooks and overrides to modify the behaviour of TinyDB. As an example, we will be configuring the name of the default table as follows −

    TinyDB.default_table_name = ''student_detail''
    

    We can also assign cache capacity as follows −

    TinyDB.table_class.default_query_cache_capacity = 50
    

    Subclassing TinyDB and Table

    This is the last way we can use to modify the behaviour of TinyDB. As an example, we will be creating a subclass that can be used with hooks and overrides to override the default classes.

    Class ExtendTable(Table):
       TinyDB.table_class = student_detail
    

    TinyDB – Extensions

    Given below is a set of TinyDB extensions that can be used for various operations −

    Sr.No. Operation & Description
    1 TinyDBTimestamps

    It is an experimental extension that can be used to automatically add and update at timestamps to TinyDB documents.

    2 aiotinydb

    It is a stable extension that enables us to use TinyDB in asyncio-aware contexts without slowing done the synchromous Input/Output(I/O).

    3 tinydb – smartcache

    It is also a stable extension. It provides users with a smart query cache. It automatically updates the query cache so that the cache does not get invalidated after inserting, updating, or removing any documents.

    4 tinydb – serialization

    It is a stable extension that provides serialization of the database object.

    5 tinydb – appengine

    It provides storage for App Engine. It is also a stable extension.

    6 Tinyrecord

    A stable extension that implements experimental atomic transaction support for the TinyDB NoSQL DB.

    7 TinyMP

    It is also stable extension used for storage based on the MessagePack.

    8 Tinymongo

    It is an experimental extension which is used for the replacement of MongoDB.

    9 Tinyindex

    It is also an experimental extension of the database. As name implies, it is used for indexing data of the database.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

    Khóa Học Miễn Phí TinyDB – Quick Guide: Cơ Hội Nhận Dự Án Có Lương!

    Bạn có biết rằng việc nắm vững các công cụ quản lý cơ sở dữ liệu có thể mở ra nhiều cơ hội nghề nghiệp thú vị và đầy tiềm năng? Nếu bạn đang tìm kiếm một khóa học miễn phí để nâng cao kỹ năng của mình và có cơ hội thực hành với các dự án thực tế, hãy tham gia ngay Khóa học Miễn phí TinyDB – Quick Guide của chúng tôi!

    khoa hoc mien phi TinyDB - Quick Guide
    khoa hoc mien phi TinyDB – Quick Guide

    Tại Sao Nên Tham Gia Khóa Học TinyDB?

    TinyDB là một cơ sở dữ liệu NoSQL nhẹ và dễ sử dụng, lý tưởng cho các dự án nhỏ, ứng dụng di động, và các ứng dụng nhúng. Với TinyDB, bạn có thể dễ dàng lưu trữ và quản lý dữ liệu mà không cần phải cấu hình phức tạp như các hệ quản trị cơ sở dữ liệu lớn.

    Khóa học TinyDB – Quick Guide sẽ trang bị cho bạn những kiến thức cơ bản và kỹ năng cần thiết để sử dụng TinyDB hiệu quả. Đây là cơ hội tuyệt vời để bạn:

    • Học Cơ Bản về TinyDB: Hiểu rõ về cấu trúc và cách hoạt động của TinyDB.
    • Thực Hành Ngay: Áp dụng kiến thức vào các bài tập thực tế.
    • Tăng Cường Kỹ Năng: Nâng cao kỹ năng lập trình và quản lý cơ sở dữ liệu.
    khoa hoc mien phi TinyDB - Quick Guide
    khoa hoc mien phi TinyDB – Quick Guide

    Nội Dung Khóa Học

    Khóa học này bao gồm:

    1. Giới thiệu về TinyDB: Khái niệm và lợi ích của TinyDB.
    2. Cài đặt và cấu hình TinyDB: Hướng dẫn từng bước để bắt đầu.
    3. Quản lý dữ liệu với TinyDB: Các thao tác cơ bản như thêm, sửa, xóa và tìm kiếm dữ liệu.
    4. Tích hợp TinyDB vào ứng dụng của bạn: Cách tích hợp TinyDB vào các dự án thực tế.
    khoa hoc mien phi TinyDB - Quick Guide
    khoa hoc mien phi TinyDB – Quick Guide

    Cơ Hội Nhận Dự Án Có Lương

    Điều đặc biệt là, sau khi hoàn thành khóa học, bạn có cơ hội nhận các dự án làm việc có lương. Đây là một phần trong chương trình hỗ trợ học viên của chúng tôi, nhằm giúp bạn áp dụng kiến thức vào thực tế và kiếm thêm thu nhập. Các dự án này sẽ được phân công dựa trên khả năng và sở thích của bạn, và chúng tôi cam kết mang đến các công việc chất lượng với mức lương hợp lý.

    khoa hoc mien phi TinyDB - Quick Guide
    khoa hoc mien phi TinyDB – Quick Guide

    Cách Đăng Ký

    Tham gia khóa học cực kỳ đơn giản! Chỉ cần:

    1. Đăng Ký: Truy cập trang đăng ký khóa học trên website của chúng tôi.
    2. Học Tập: Tham gia các bài giảng và bài tập theo lịch trình của khóa học.
    3. Nhận Dự Án: Sau khi hoàn thành khóa học, đăng ký nhận dự án và bắt đầu làm việc ngay.
    khoa hoc mien phi TinyDB - Quick Guide
    khoa hoc mien phi TinyDB – Quick Guide

    Đăng Ký Ngay Hôm Nay!

    Đừng bỏ lỡ cơ hội tuyệt vời này để nâng cao kỹ năng và mở rộng cơ hội nghề nghiệp của bạn. Khóa học TinyDB – Quick Guide hoàn toàn miễn phí và mở ra cánh cửa để bạn có thể nhận các dự án thực tế có lương.

    Hãy đăng ký ngay hôm nay và bước vào hành trình học tập và làm việc thú vị với TinyDB!


    Chúng tôi mong được đồng hành cùng bạn trên con đường phát triển nghề nghiệp!

    Nếu bạn có bất kỳ câu hỏi nào hoặc cần thêm thông tin, đừng ngần ngại liên hệ với chúng tôi qua email hoặc trang hỗ trợ trên website.Khóa Học Miễn Phí TinyDB – Quick Guide: Cơ Hội Nhận Dự Án Có Lương!

    https://youtu.be/9DFRyQO_d_E?si=-oEd7Xj4kNisRhM_
  • Khóa học miễn phí TinyDB – Storage Types nhận dự án làm có lương

    Khóa học miễn phí TinyDB – Storage Types nhận dự án làm có lương


    TinyDB – Storage Types



    TinyDB has two types of storage: JSON and in-memory. TinyDB, by default, stores the data in JSON files. While creating a database, you need to specify the path where to store the JSON file on your computer.

    Storing Data in a JSON File

    First, let”s see how we can use a JSON file to store the data −

    from tinydb import TinyDB, where
    db = TinyDB(''path/to/file_name.json'')
    

    Example 1

    In this example, we are showing how you can insert multiple documents into a JSON file −

    from tinydb import TinyDB
    db = TinyDB(''storage.json'')
    db.insert_multiple([
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakhan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"oracle",
          "address":"benglore"
       }
    ])
    

    Here, we inserted 5 documents inside “storage.json”. To verify the records, use the following query −

    db.all()
    

    It will show the contents of “storage.json” file −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakhan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"oracle",
          "address":"benglore"
       }
    ]
    

    Using in-memory to Store Data

    Now, let”s see how we can use “in-memory” to store the data −

    from tinydb import TinyDB
    from tinydb.storages import MemoryStorage
    object = TinyDB(storage = MemoryStorage)
    TinyDB.DEFAULT_STORAGE = MemoryStorage
    

    Example 2

    The following example shows how you can insert multiple documents in default storage memory −

    from tinydb import TinyDB
    from tinydb.storages import MemoryStorage
    object = TinyDB(storage = MemoryStorage)
    TinyDB.DEFAULT_STORAGE = MemoryStorage
    object.insert_multiple([
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"oracle",
          "address":"benglore"
       }
    ])
    

    To verify whether the documents have been inserted or not, use the following query −

    object.all()
    

    The following output shows the inserted data −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"oracle",
          "address":"benglore"
       }
    ]
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

    Khóa Học Miễn Phí TinyDB – Storage Types: Cơ Hội Nhận Dự Án Có Lương

    Trong thời đại công nghệ hiện đại, việc hiểu và quản lý các loại lưu trữ dữ liệu là điều rất quan trọng đối với các nhà phát triển và chuyên gia dữ liệu. TinyDB, một thư viện cơ sở dữ liệu NoSQL nhẹ dành cho Python, cung cấp nhiều tùy chọn lưu trữ linh hoạt và hiệu quả. Để giúp các bạn làm quen với các loại lưu trữ trong TinyDB, chúng tôi xin giới thiệu khóa học miễn phí “TinyDB – Storage Types”, đồng thời mở ra cơ hội nhận các dự án thực tế có lương.

    khoa hoc mien phi TinyDB – Storage Types
    khoa hoc mien phi TinyDB – Storage Types

    Giới Thiệu Về TinyDB và Các Loại Lưu Trữ

    TinyDB là một thư viện cơ sở dữ liệu nhỏ gọn cho Python, nổi bật với sự đơn giản và khả năng lưu trữ dữ liệu dưới dạng JSON. Tuy đơn giản, TinyDB vẫn cung cấp các tùy chọn lưu trữ linh hoạt để đáp ứng nhu cầu đa dạng của người dùng. Khóa học “TinyDB – Storage Types” sẽ giúp bạn nắm vững cách sử dụng và quản lý các loại lưu trữ trong TinyDB, từ các cấu trúc đơn giản đến các kỹ thuật lưu trữ nâng cao.

    khoa hoc mien phi TinyDB – Storage Types
    khoa hoc mien phi TinyDB – Storage Types

    Nội Dung Khóa Học

    Khóa học “TinyDB – Storage Types” bao gồm các nội dung chính sau:

    1. Giới Thiệu Về TinyDB: Tổng quan về TinyDB và các thành phần cơ bản của nó, cùng với khái niệm về các loại lưu trữ dữ liệu.
    2. Các Loại Lưu Trữ Cơ Bản: Tìm hiểu về các phương pháp lưu trữ cơ bản trong TinyDB, bao gồm lưu trữ dữ liệu dưới dạng JSON và cách cấu hình lưu trữ.
    3. Lưu Trữ Nâng Cao: Khám phá các tùy chọn lưu trữ nâng cao, bao gồm các kỹ thuật tối ưu hóa và các mô hình lưu trữ phức tạp hơn.
    4. Quản Lý và Bảo Trì Dữ Liệu: Cách quản lý và bảo trì dữ liệu hiệu quả trong TinyDB, bao gồm các phương pháp sao lưu và phục hồi dữ liệu.
    5. Ứng Dụng Thực Tiễn: Xây dựng các ứng dụng thực tế sử dụng các loại lưu trữ trong TinyDB để củng cố kiến thức và kỹ năng của bạn.
    khoa hoc mien phi TinyDB – Storage Types
    khoa hoc mien phi TinyDB – Storage Types

    Lợi Ích Khi Tham Gia Khóa Học

    1. Miễn Phí Hoàn Toàn: Khóa học hoàn toàn miễn phí, giúp bạn tiết kiệm chi phí học tập và tiếp cận kiến thức chất lượng cao.
    2. Kỹ Năng Quản Lý Lưu Trữ: Bạn sẽ học được cách quản lý và tối ưu hóa các loại lưu trữ dữ liệu trong TinyDB, điều này rất hữu ích cho các dự án thực tế.
    3. Dự Án Thực Tế Có Lương: Sau khi hoàn thành khóa học, bạn có cơ hội nhận các dự án thực tế có lương để áp dụng những gì đã học và kiếm thêm thu nhập.
    4. Hỗ Trợ Chuyên Nghiệp: Đội ngũ giảng viên giàu kinh nghiệm sẽ hỗ trợ bạn trong suốt khóa học, đảm bảo bạn có được sự hướng dẫn và hỗ trợ cần thiết.
    5. Cơ Hội Phát Triển Nghề Nghiệp: Khóa học không chỉ giúp bạn nâng cao kỹ năng mà còn mở ra cơ hội nghề nghiệp hấp dẫn thông qua các dự án có lương.
    khoa hoc mien phi TinyDB – Storage Types
    khoa hoc mien phi TinyDB – Storage Types

    Cơ Hội Nhận Dự Án Có Lương

    Một trong những điểm nổi bật của khóa học “TinyDB – Storage Types” là cơ hội nhận các dự án thực tế có lương. Sau khi hoàn thành khóa học, bạn có thể tham gia vào các dự án liên quan đến TinyDB, áp dụng kiến thức về các loại lưu trữ và nhận thù lao cho công việc của mình. Đây là cơ hội tuyệt vời để tích lũy kinh nghiệm thực tế, đồng thời kiếm thêm thu nhập.

    khoa hoc mien phi TinyDB – Storage Types
    khoa hoc mien phi TinyDB – Storage Types

    Cách Đăng Ký

    Để tham gia khóa học, bạn có thể đăng ký qua trang web chính thức của khóa học hoặc liên hệ với đơn vị tổ chức để được hướng dẫn chi tiết. Đừng bỏ lỡ cơ hội học hỏi và phát triển kỹ năng quản lý lưu trữ dữ liệu với TinyDB, đồng thời kiếm thêm thu nhập từ các dự án thực tế!

    Khóa học “TinyDB – Storage Types” không chỉ cung cấp kiến thức chuyên sâu về các loại lưu trữ dữ liệu trong TinyDB mà còn mở ra cơ hội nghề nghiệp hấp dẫn. Hãy đăng ký ngay hôm nay để bắt đầu hành trình học tập và phát triển nghề nghiệp của bạn!

    https://youtu.be/B-SyPsaUy08?si=uRKwg0nZAEjxvSou
  • Khóa học miễn phí TinyDB – Middleware nhận dự án làm có lương

    Khóa học miễn phí TinyDB – Middleware nhận dự án làm có lương


    TinyDB – Middleware



    TinyDB middleware helps us to customize database storage behavior by wrapping around the existing storage. This middleware improves the performance of the database.

    Caching Middleware

    This middleware, as its name implies, improves the speed of a database by reducing the disk I/O. The working of CachingMiddleware is as follows −

    • First, it catches all the read operations.

    • Then it writes the data to the disk after a configured number of write operations.

    Syntax

    The syntax to use CachingMiddleware is as follows −

    from tinydb.storages import JSONStorage
    from tinydb.middlewares import CachingMiddleware
    db = TinyDB(''middleware.json'', storage = CachingMiddleware(JSONStorage))
    db.close()
    

    Example

    The following example shows how you can perform a basic middleware procedure in a database.

    from tinydb import TinyDB
    from tinydb.storages import JSONStorage
    from tinydb.middlewares import CachingMiddleware
    object = TinyDB(''storage.json'', storage=CachingMiddleware(JSONStorage))
    object.all()
    

    Output

    It will produce the following output −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":2,
          "st_name":"Ram",
          "mark":[
             250,
             280
          ],
          "subject":[
             "TinyDB",
             "MySQL"
          ],
          "address":"delhi"
       },
       {
          "roll_number":3,
          "st_name":"kevin",
          "mark":[
             180,
             200
          ],
          "subject":[
             "oracle",
             "sql"
          ],
          "address":"keral"
       },
       {
          "roll_number":4,
          "st_name":"lakan",
          "mark":200,
          "subject":"MySQL",
          "address":"mumbai"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"oracle",
          "address":"benglore"
       }
    ]
    

    Close the database to make sure that all the data is safely written.

    db.close()
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

    Khóa Học Miễn Phí TinyDB – Middleware: Nhận Dự Án Làm Có Lương!

    Bạn đang tìm kiếm một cơ hội để nâng cao kỹ năng quản lý cơ sở dữ liệu và làm việc trên các dự án thực tế? Khóa học miễn phí TinyDB – Middleware chính là cơ hội lý tưởng cho bạn! Tham gia khóa học này không chỉ giúp bạn làm chủ TinyDB mà còn mở ra cánh cửa nhận các dự án làm việc có lương. Hãy cùng tìm hiểu chi tiết về khóa học hấp dẫn này nhé!

    khoa hoc mien phi TinyDB – Middleware
    khoa hoc mien phi TinyDB – Middleware

    Tại Sao Nên Tham Gia Khóa Học TinyDB – Middleware?

    TinyDB là một cơ sở dữ liệu NoSQL nổi bật nhờ tính nhẹ, dễ sử dụng và khả năng tích hợp tốt với các ứng dụng nhỏ và nhúng. Trong khi đó, Middleware đóng vai trò quan trọng trong việc kết nối và truyền dữ liệu giữa các ứng dụng và cơ sở dữ liệu. Khóa học TinyDB – Middleware sẽ trang bị cho bạn những kiến thức cần thiết để làm việc hiệu quả với TinyDB trong vai trò của một middleware.

    khoa hoc mien phi TinyDB – Middleware
    khoa hoc mien phi TinyDB – Middleware

    Khóa học này cung cấp:

    • Kiến thức về TinyDB: Nắm vững các khái niệm cơ bản và nâng cao của TinyDB.
    • Kỹ năng làm việc với Middleware: Hiểu rõ cách thức hoạt động của middleware và cách tích hợp TinyDB với các ứng dụng khác.
    • Thực hành ngay: Thực hiện các bài tập thực tế để củng cố kiến thức và kỹ năng của bạn.
    khoa hoc mien phi TinyDB – Middleware
    khoa hoc mien phi TinyDB – Middleware

    Nội Dung Khóa Học

    Khóa học TinyDB – Middleware sẽ bao gồm các nội dung sau:

    1. Giới thiệu về TinyDB: Tìm hiểu về TinyDB và các ứng dụng của nó.
    2. Khái niệm về Middleware: Định nghĩa, vai trò và các loại middleware trong hệ thống phần mềm.
    3. Cài đặt và cấu hình TinyDB như Middleware: Hướng dẫn thiết lập TinyDB để hoạt động như một middleware hiệu quả.
    4. Tích hợp TinyDB với các ứng dụng: Cách kết nối TinyDB với các ứng dụng khác qua middleware.
    5. Thực hành với các dự án thực tế: Áp dụng kiến thức vào các bài tập và dự án thực tế.
    khoa hoc mien phi TinyDB – Middleware
    khoa hoc mien phi TinyDB – Middleware

    Cơ Hội Nhận Dự Án Làm Có Lương

    Sau khi hoàn thành khóa học, bạn sẽ có cơ hội nhận các dự án làm việc có lương. Đây là một phần trong chương trình hỗ trợ của chúng tôi nhằm giúp bạn áp dụng kiến thức đã học vào thực tiễn và kiếm thêm thu nhập. Các dự án này được thiết kế để phù hợp với kỹ năng của bạn và giúp bạn phát triển nghề nghiệp trong lĩnh vực quản lý cơ sở dữ liệu và middleware.

    khoa hoc mien phi TinyDB – Middleware
    khoa hoc mien phi TinyDB – Middleware

    Cách Đăng Ký

    Tham gia khóa học TinyDB – Middleware rất đơn giản:

    1. Đăng Ký: Truy cập trang đăng ký trên website của chúng tôi và hoàn tất thông tin cần thiết.
    2. Tham Gia Khóa Học: Thực hiện theo lịch trình học tập và hoàn thành các bài tập.
    3. Nhận Dự Án: Sau khi hoàn thành khóa học, đăng ký nhận các dự án làm việc và bắt đầu thực hiện.

    Đăng Ký Ngay Để Không Bỏ Lỡ!

    Đừng bỏ lỡ cơ hội tuyệt vời này để nâng cao kỹ năng và mở rộng cơ hội nghề nghiệp của bạn. Khóa học TinyDB – Middleware hoàn toàn miễn phí và mang đến cơ hội nhận các dự án thực tế có lương.

    Hãy đăng ký ngay hôm nay và bắt đầu hành trình học tập và làm việc với TinyDB!

    https://youtu.be/wgFdZAOERoc?si=nXLSeaSHdNnFiRXR

    Chúng tôi rất mong được đồng hành cùng bạn trong hành trình học tập và phát triển nghề nghiệp.

    Nếu bạn có bất kỳ câu hỏi nào hoặc cần thêm thông tin, vui lòng liên hệ với chúng tôi qua email hoặc trang hỗ trợ trên website.

  • Khóa học miễn phí TinyDB – The Test() Query nhận dự án làm có lương

    Khóa học miễn phí TinyDB – The Test() Query nhận dự án làm có lương


    TinyDB – The test() Query



    The test() query will test if the given arguments match with the data in a table. If it matches with the data, it will return the matched data, otherwise it will return blank. First of all, we need to define a test function and its arguments and then it will search the item in a given database.

    Syntax

    The syntax of TinyDB test() is as follows −

    db.search(Query().field.test(function or condition, *arguments))
    

    Here, field represents the part of data that we want to access. Query() is the object created of our JSON table named student.

    We can create a custom test function as follows −

    object = lambda t: t == ''value''
    

    Here the lamba keyword is important to create the custom test function.

    Let”s understand how it works with the help of a couple of examples. We will use the same student database that we have used in all the previous chapters.

    Example 1

    We will first create a test function and then use it in our student table −

    from tinydb import TinyDB, Query
    db = TinyDB(''student.json'')
    objects = lambda t: t == [250, 280]
    db.search(Query().mark.test(objects))
    

    It will fetch the rows where the “mark” field has the values [250, 280] −

    [{''roll_number'': 2, ''st_name'': ''Ram'', ''mark'': [250, 280], ''subject'':
    [''TinyDB'', ''MySQL''], ''address'': ''delhi''}]
    

    Example 2

    In this example, we will use the “subject” field in the test function −

    student = Query()
    db = TinyDB(''student.json'')
    objects = lambda t: t == ''TinyDB''
    db.search(student.subject.test(objects))
    

    This query will fetch all the rows where the “subject” field has the value “TinyDB” −

    [
       {
          "roll_number":1,
          "st_name":"elen",
          "mark":250,
          "subject":"TinyDB",
          "address":"delhi"
       },
       {
          "roll_number":5,
          "st_name":"karan",
          "mark":275,
          "subject":"TinyDB",
          "address":"benglore"
       }
    ]
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

    Khóa Học Miễn Phí TinyDB – The Test() Query: Cơ Hội Nhận Dự Án Làm Có Lương!

    Bạn đang tìm kiếm cơ hội để nâng cao kỹ năng quản lý cơ sở dữ liệu và làm việc trên các dự án thực tế? Khóa học miễn phí TinyDB – The Test() Query chính là cơ hội lý tưởng dành cho bạn! Tham gia khóa học này không chỉ giúp bạn hiểu rõ cách sử dụng hàm test() trong TinyDB mà còn mở ra cơ hội nhận các dự án thực tế có lương. Hãy cùng khám phá chi tiết về khóa học và những lợi ích mà nó mang lại!

    khoa hoc mien phi TinyDB – The Test() Query
    khoa hoc mien phi TinyDB – The Test() Query

    Tại Sao Nên Tham Gia Khóa Học TinyDB – The Test() Query?

    TinyDB là một cơ sở dữ liệu NoSQL nhẹ, dễ sử dụng, rất phù hợp cho các ứng dụng nhỏ và nhúng. Hàm test() trong TinyDB là một công cụ mạnh mẽ giúp bạn kiểm tra điều kiện và thực hiện các truy vấn dữ liệu linh hoạt. Khóa học TinyDB – The Test() Query sẽ cung cấp cho bạn kiến thức cần thiết để sử dụng hàm test() một cách hiệu quả, giúp bạn tối ưu hóa việc truy vấn và phân tích dữ liệu.

    Khóa học này sẽ cung cấp cho bạn:

    • Kiến Thức Về Hàm test(): Hiểu rõ vai trò và cách sử dụng hàm test() trong TinyDB để thực hiện các truy vấn điều kiện.
    • Kỹ Năng Xử Lý Truy Vấn: Học cách áp dụng hàm test() để xây dựng các truy vấn phức tạp và linh hoạt.
    • Thực Hành Tinh Thông: Áp dụng kiến thức vào các bài tập và dự án thực tế để củng cố kỹ năng.
    khoa hoc mien phi TinyDB – The Test() Query
    khoa hoc mien phi TinyDB – The Test() Query

    Nội Dung Khóa Học

    Khóa học TinyDB – The Test() Query bao gồm các nội dung chính sau:

    1. Giới Thiệu về TinyDB: Tìm hiểu về cấu trúc cơ bản và các tính năng của TinyDB.
    2. Khái Niệm Về Hàm test(): Định nghĩa và vai trò của hàm test() trong việc thực hiện các truy vấn điều kiện.
    3. Sử Dụng Hàm test(): Hướng dẫn chi tiết về cách sử dụng hàm test() để thực hiện các truy vấn dữ liệu linh hoạt và phức tạp.
    4. Tối Ưu Hóa Truy Vấn: Cách tối ưu hóa việc sử dụng hàm test() để cải thiện hiệu suất và khả năng mở rộng của hệ thống.
    5. Dự Án Thực Tế: Áp dụng các kiến thức vào các bài tập và dự án thực tế để nâng cao kỹ năng.
    khoa hoc mien phi TinyDB – The Test() Query
    khoa hoc mien phi TinyDB – The Test() Query

    Cơ Hội Nhận Dự Án Làm Có Lương

    Sau khi hoàn thành khóa học, bạn có cơ hội nhận các dự án thực tế có lương. Đây là một phần trong chương trình hỗ trợ học viên của chúng tôi, giúp bạn áp dụng kiến thức vào công việc thực tế và kiếm thêm thu nhập. Các dự án này sẽ được phân công dựa trên kỹ năng và sở thích của bạn, đảm bảo bạn có thể làm việc hiệu quả và phát triển sự nghiệp trong lĩnh vực quản lý cơ sở dữ liệu.

    khoa hoc mien phi TinyDB – The Test() Query
    khoa hoc mien phi TinyDB – The Test() Query

    Cách Đăng Ký

    Để tham gia khóa học TinyDB – The Test() Query, bạn chỉ cần:

    1. Đăng Ký: Truy cập trang đăng ký trên website của chúng tôi và hoàn tất các bước đăng ký.
    2. Tham Gia Khóa Học: Theo dõi lịch trình học tập và hoàn thành các bài tập theo yêu cầu.
    3. Nhận Dự Án: Sau khi hoàn thành khóa học, bạn có thể đăng ký nhận các dự án làm việc có lương và bắt đầu thực hiện.

    Đăng Ký Ngay Để Không Bỏ Lỡ!

    Khóa học TinyDB – The Test() Query hoàn toàn miễn phí và mở ra cơ hội để bạn nâng cao kỹ năng truy vấn dữ liệu và nhận các dự án thực tế có lương. Đừng bỏ lỡ cơ hội tuyệt vời này để phát triển sự nghiệp của bạn trong lĩnh vực quản lý cơ sở dữ liệu.

    https://www.youtube.com/watch?v=5I7XvTHG_mk&t=30s

    Hãy đăng ký ngay hôm nay và bắt đầu hành trình học tập và làm việc với TinyDB!


    Chúng tôi rất mong được đồng hành cùng bạn trong việc nâng cao kỹ năng và phát triển nghề nghiệp.

    Nếu bạn có bất kỳ câu hỏi nào hoặc cần thêm thông tin, vui lòng liên hệ với chúng tôi qua email hoặc trang hỗ trợ trên website.