I recently saw a document on https://docs.sqlalchemy.org/en/14/core/dml.html#sqlalchemy.sql.expression.insert.
I want to know why insert()
is declared under sqlalchemy.sql.expression
, and we can still import it by from sqlalchemy import insert
.
Answer
It’s defined here: https://github.com/sqlalchemy/sqlalchemy/blob/master/lib/sqlalchemy/__init__.py#L53
__init__.py
is a file that runs automatically whenever the folder is imported in Python.