Category: tinydb

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

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


    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"
       }
    ]
    

    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 All() Query: Cơ Hội Nhận Dự Án Làm Có Lương!

    Bạn muốn cải thiện kỹ năng truy vấn dữ liệu và khám phá những cơ hội nghề nghiệp hấp dẫn? Khóa học miễn phí TinyDB – The All() Query 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 rõ cách sử dụng hàm all() 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 All() Query
    khoa hoc mien phi TinyDB – The All() Query

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

    TinyDB là một cơ sở dữ liệu NoSQL nhẹ và dễ sử dụng, phù hợp cho các ứng dụng nhỏ và nhúng. Hàm all() trong TinyDB là công cụ quan trọng giúp bạn thực hiện các truy vấn dữ liệu dựa trên tất cả các điều kiện trong một tập hợp. Khóa học TinyDB – The All() Query sẽ trang bị cho bạn những kiến thức cần thiết để sử dụng hàm all() một cách hiệu quả, giúp bạn tối ưu hóa việc truy vấn và quản lý dữ liệu.

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

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

    • Kiến Thức Về Hàm all(): Hiểu rõ cách sử dụng hàm all() để thực hiện các truy vấn dữ liệu dựa trên tất cả các điều kiện.
    • Kỹ Năng Truy Vấn Dữ Liệu: Học cách áp dụng hàm all() để tìm kiếm và lọc dữ liệu một cách chính xác và hiệu quả.
    • 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 All() Query
    khoa hoc mien phi TinyDB – The All() Query

    Nội Dung Khóa Học

    Khóa học TinyDB – The All() 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 all(): Định nghĩa và vai trò của hàm all() trong việc thực hiện các truy vấn dữ liệu dựa trên tất cả các điều kiện.
    3. Sử Dụng Hàm all(): Hướng dẫn chi tiết về cách sử dụng hàm all() để thực hiện các truy vấn dữ liệu linh hoạt.
    4. Tối Ưu Hóa Truy Vấn: Cách tối ưu hóa việc sử dụng hàm all() để cải thiện hiệu suất và độ chính xác của các truy vấn.
    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.

    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.

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

    Cách Đăng Ký

    Để tham gia khóa học TinyDB – The All() 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 All() 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.

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

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

    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"
       }
    ]
    

    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 – Logical AND nhận dự án làm có lương

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


    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''
    }]
    

    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 – Logical AND: Cơ Hội Nhận Dự Án Làm Có Lương!

    Bạn muốn cải thiện kỹ năng truy vấn dữ liệu của mình và làm việc trên các dự án thực tế có lương? Khóa học miễn phí TinyDB – Logical AND 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 nắm vững cách sử dụng phép toán Logical AND trong TinyDB mà còn mở ra cơ hội nhận các dự án thực tế có lương. 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 – Logical AND
    khoa hoc mien phi TinyDB – Logical AND

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

    TinyDB là một cơ sở dữ liệu NoSQL nhẹ, đơn giản và dễ sử dụng, lý tưởng cho các ứng dụng nhỏ và nhúng. Phép toán Logical AND là một công cụ quan trọng trong việc thực hiện các truy vấn dữ liệu phức tạp, cho phép bạn kết hợp nhiều điều kiện để lọc dữ liệu chính xác hơn. Khóa học TinyDB – Logical AND sẽ cung cấp cho bạn những kiến thức cần thiết để sử dụng phép toán Logical AND một cách hiệu quả trong các truy vấn dữ liệu.

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

    • Kiến Thức Về Logical AND: Hiểu rõ cách sử dụng phép toán Logical AND trong TinyDB để kết hợp nhiều điều kiện trong các truy vấn.
    • Kỹ Năng Truy Vấn Dữ Liệu: Học cách áp dụng phép toán Logical AND để tạo ra các truy vấn linh hoạt và chính xác.
    • 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 – Logical AND
    khoa hoc mien phi TinyDB – Logical AND

    Nội Dung Khóa Học

    Khóa học TinyDB – Logical AND 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ề Logical AND: Định nghĩa và vai trò của phép toán Logical AND trong việc thực hiện các truy vấn dữ liệu.
    3. Sử Dụng Logical AND: Hướng dẫn chi tiết về cách sử dụng phép toán Logical AND để kết hợp nhiều điều kiện trong các truy vấn dữ liệu.
    4. Tối Ưu Hóa Truy Vấn: Cách tối ưu hóa việc sử dụng phép toán Logical AND để cải thiện hiệu suất và độ chính xác của các truy vấn.
    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 – Logical AND
    khoa hoc mien phi TinyDB – Logical AND

    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.

    Cách Đăng Ký

    Để tham gia khóa học TinyDB – Logical AND, 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 – Logical AND
    khoa hoc mien phi TinyDB – Logical AND

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

    Khóa học TinyDB – Logical AND 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.

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

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


    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.


    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 – Handling Data Query: Cơ Hội Nhận Dự Án Làm Có Lương!

    Bạn có muốn làm chủ kỹ năng truy vấn dữ liệu trong TinyDB và tận dụng các cơ hội nghề nghiệp hấp dẫn? Khóa học miễn phí TinyDB – Handling Data 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 nắm vững cách xử lý và tối ưu hóa các truy vấn dữ liệu 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 – Handling Data Query
    khoa hoc mien phi TinyDB – Handling Data Query

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

    TinyDB là một cơ sở dữ liệu NoSQL nhẹ và dễ sử dụng, lý tưởng cho các ứng dụng nhỏ và nhúng. Kỹ năng xử lý truy vấn dữ liệu là rất quan trọng trong việc khai thác hiệu quả thông tin từ cơ sở dữ liệu. Khóa học TinyDB – Handling Data Query sẽ giúp bạn hiểu rõ cách thực hiện và tối ưu hóa các truy vấn dữ liệu trong TinyDB, từ việc tìm kiếm đơn giản đến các yêu cầu truy vấn phức tạp hơn.

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

    • Kiến Thức Về Truy Vấn Dữ Liệu: Hiểu rõ cách thực hiện các truy vấn dữ liệu cơ bản và nâng cao trong TinyDB.
    • Kỹ Năng Xử Lý Truy Vấn: Học cách tối ưu hóa các truy vấn để cải thiện hiệu suất và độ chính xác.
    • 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 – Handling Data Query
    khoa hoc mien phi TinyDB – Handling Data Query

    Nội Dung Khóa Học

    Khóa học TinyDB – Handling Data 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ề Truy Vấn Dữ Liệu: Định nghĩa và vai trò của các truy vấn dữ liệu trong TinyDB.
    3. Thực Hiện Truy Vấn Cơ Bản: Hướng dẫn chi tiết về cách thực hiện các truy vấn dữ liệu cơ bản, bao gồm tìm kiếm, lọc, và sắp xếp.
    4. Tối Ưu Hóa Truy Vấn: Cách tối ưu hóa truy vấn để 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 – Handling Data Query
    khoa hoc mien phi TinyDB – Handling Data 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.

    Cách Đăng Ký

    Để tham gia khóa học TinyDB – Handling Data 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.
    khoa hoc mien phi TinyDB – Handling Data Query
    khoa hoc mien phi TinyDB – Handling Data Query

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

    Khóa học TinyDB – Handling Data Query hoàn toàn miễn phí và mở ra cơ hội để bạn nâng cao kỹ năng xử lý 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.

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

    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
    

    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 – Searching nhận dự án làm có lương

    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''
    }]
    

    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 – Update Data nhận dự án làm có lương

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


    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 – Home nhận dự án làm có lương

    TinyDB Tutorial

    TinyDB Tutorial







    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.

    Audience

    TinyDB tutorial is helpful to learn from students to professionals in easy steps. This tutorial is designed for beginners to advance level developers for a web application. This tutorial makes you an intermediate or advanced level expert with practice.

    Prerequisites

    To learn this tutorial, you need to know about the Python version of your computer. You must know the working procedure of the command prompt. You do not need to learn coding language or install the software.

    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 – Querying nhận dự án làm có lương

    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"
    }]
    

    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