Article From:

1. concept”

  1. Target: class / object operation -> SQL statement -> DB API -> and then executed in database. ORM does the first two parts, because ORM itself cannot operate the database. Reference: Fr=aladdin
  2. Essence: class (Users) corresponds to the database table, and the attributes in the class correspond to the columns in the database table.
class Users(Base):
    __tablename__ = 'users' # Database table nameId = Column (Integer, primary_key=True) primary key of IDName = Column (String (32), index=True,Nullable=False) name column,

2. SQLAlchemy

2.1 SQLAlch.”Emy is a ORM framework based on Python implementation. The framework is built on DB API, using relational object mapping for database operations. In short, the class and object are converted to SQL, then the database API is used to execute SQL and the execution results are obtained.

Engine,The engine of the frame
Connection Pooling ,Database connection pool
Dialect,Select the type of DB API that connects the database
Schema/Types,Architecture and type
SQL Exprression Language,SQLExpression language

2.2 SQLAlchemy itself is inoperable.”According to the library, it must be pymsql and other three party plug-ins, Dialect is used to communicate with data API, and the different database API is called according to the different configuration files, so as to realize the operation of the database, such as:

This heap string is in Dialect

Link of this Article: Python – ORM (database related)

Leave a Reply

Your email address will not be published. Required fields are marked *