/ PYTHON

Python(6) - ORM(Object-Relational Mapping)

Python 관련 포스팅

Django ORM을 사용하면서 드는 의문점을 해결하기 위해 쓰는 글입니다.

1. ORM이란?

객체-지향

Object-Relational Mapping (ORM) is a technique that lets you query and manipulate data from a database using an object-oriented paradigm. When talking about ORM, most people are referring to a library that implements the Object-Relational Mapping technique, hence the phrase “an ORM”.

An ORM library is a completely ordinary library written in your language of choice that encapsulates the code needed to manipulate the data, so you don’t use SQL anymore; you interact directly with an object in the same language you’re using.

For example, here is a completely imaginary case with a pseudo language:

You have a book class, you want to retrieve all the books of which the author is “Linus”. Manually, you would do something like that: