0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【DjangoのDB操作】ORM / querysetとは

Posted at

はじめに

Djangoでwebアプリケーションを作成する上でORMという単語を初めて知ったので意味を調べました。

ORMとは

ORMはObject-Relational-Mappingの略で、オブジェクト指向型言語でRDBを扱う手法です。

DjangoのORMでできること

  • PythonのクラスをDBのテーブルに対応させる役割を果たすため、開発者はSQLを書かずにDBとのやり取り(CRUD)が可能
    ⇨ DB操作のためのコードの単純化、可読性の向上、エラーの減少

  • マイグレーション機能により、コードでのDBのスキーマの変更の定義・DBへの適用が可能
    ⇨ DBのスキーマ変更が簡単に行える、チーム内でのスキーマ変更の共有が可能

querysetとは

Djangoのメソッドを使用してDBからデータを取得するとき、データはQueryset型としてDBから取り出され、これらのデータはquerysetと言います。
querysetの操作メソッド一覧

参考サイト

querysetについて分かりやすく解説【具体例で説明します】
ORMとは?|SQLAlchemy 概要と基本の使い方

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?