程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Django web minimalist tutorial (V) - Django ORM (part a)

編輯:Python

One 、ORM

ORM Both Object Relational Mapping, By using ORM You can use it directly Python Code operation database , Instead of writing tedious SQL. ORM By mapping tables to Model Model ( class ), The fields in the table and Model The attributes in the model correspond to each other ,ORM When the object operation is executed, the corresponding operation will be converted into the native statement of the database SQL Implementation .

Simply speaking ,ORM

  • Easy to use , By encapsulating the database Syntax , Use it directly Python Method to manipulate the database , perform SQL sentence
  • Good performance , Though through ORM Convert to native SQL There will be a little loss of performance , But this loss is related to SQL Execution or relative to overall business improvement is almost negligible .
  • Compatibility is good. , Support multiple relational databases , Such as M ySQL、PostgreSQL、SQLite

Of course ,Python There are more third parties in the ORM frame , such as SqlAlchemy、peebee、Storm etc. ,SQLAlchemy yes Flask The most widely used ORM frame , and Django It's built in ORM frame

Django Medium ORM

differ Flask The framework needs the help of flaks-sqlalchemy Extend to achieve ORM,Django Frame itself ORM, There is no need to install related ORM Expand , But you need to install the relevant database drivers .

Django Virtual object databases in can also be called models , Read and write the target database through the model , The operation steps are as follows :


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved