Contribute Media
A thank you to everyone who makes this possible: Read More

How to manage various and complex Python objects in a database using Type Annotation

Description

Let's learn how to store complex JSON data in a database using type annotations that indicate type information in Python. Using Pydantic, which is also used in FastAPI, you can extract information from fields and convert them to JSON. Based on this function, we will define various data types necessary for defining a database table schema, and discuss how to make a specific key value an indexed database field value or an array value an index. Furthermore, we will discuss methods for effectively searching and processing nested objects within objects. We will explain Python's type annotations and briefly show how type information is stored. The basic usage of Pydantic and some of Mariadb's JSON-related functions will also be discussed. Using Pydantic and SQLAlchemy, you can manage objects that exactly correspond to database table fields, but it is difficult to process diverse and complex data. Using the method we shared, you can also store complex objects. Using this library, you can easily create an expandable Rest API related to a database. We will also share the detailed implementation source. Although not mentioned in the presentation, I think it would be helpful to refer to it as it also implements frequently shared objects, definitions of objects that can be joined together, methods for storing various types of objects, and a full text search function.

Improve this page