一孔的 Python

@ycpython

yicong的Python

Private team

Joined on Jul 7, 2023

  • SQLAlchemy is a ORM, psycopg2 is a database driver. These are completely different things: SQLAlchemy generates SQL statements and psycopg2 sends SQL statements to the database. SQLAlchemy depends on psycopg2 or other database drivers to communicate with the database! As a rather complex software layer SQLAlchemy does add some overhead but it also is a huge boost to development speed, at least once you learned the library. SQLAlchemy is an excellent library and will teach you the whole ORM concept, but if you don't want to generate SQL statements to begin with then you don't want SQLAlchemy. SQLAlchemy 是一個 ORM(物件關係對映),psycopg2 是一個資料庫驅動程式,這兩者是完全不同的東西。 SQLAlchemy 用於生成 SQL 語句 psycopg2 用於將 SQL 語句發送到資料庫 SQLAlchemy 依賴於 psycopg2 或其他資料庫驅動程式來與資料庫進行通訊!
     Like  Bookmark
  • 模型入門 本章節簡要概述了模型定義,和一些重要的欄位、和欄位參數。 模型定義 模型通常在 app 中的 models.py 檔案中定義。它們是繼承自 django.db.models.Model的子類別,可以包括屬性,方法和描述性資料(metadata)。以下的程式碼片段是一個名為MyModelName的「典型」模型範例碼: from django.db import models class MyModelName(models.Model): """A typical class defining a model, derived from the Model class."""
     Like  Bookmark
  • 使用 django-admin 產生專案資料夾資料夾內會包含「基礎檔案範本」及「manage.py」 「manage.py」可以提供各式「專案管理腳本工具」 使用 manage.py 建立一個或多個 application (簡稱app) ::: info app 的概念 一個網站可能由多個部分組成,比如,主要頁面,部落格,wiki,下載專區等。Django 鼓勵將這些部分作為分開的app開發。如此一來,就可以在不同的專案中重複使用這些app。 ::::
     Like  Bookmark