Programing/DataBase / / 2021. 12. 15. 20:02

ORM이란?

- Object Relational Mapping, 객체 - 관계 매핑을 의미

 

- 데이터베이스 데이터 <- 매핑 -> Object 필드 

 

예시로, Python Class 같은 python object 자료형들을 DB table로 매핑 하는 것


class Article:
    def __init__(self,id,title,content,author,created_at):
        self.id=id
        self.title=title
        self.content=content
        self.author=author
        self.created_at=created_at
        
a1 = Article(1,'제목입니다','내용입니다','신동찬','2019-02-07')
a2 = Article(2,'제목입니다','내용입니다','신동찬','2019-02-07')

articles3 = [
    a1,a2    
]

ref. https://dongchans.github.io/2019/28/

 

- 장점은 클래스로 접근하면 아래와 같이 데이터를 관리할 수 있음

 

class Article:
    def delete(self):
        del(self)
  • 네이버 블로그 공유
  • 네이버 밴드 공유
  • 페이스북 공유
  • 카카오스토리 공유