So I am making new flask app and noticed even in other projects that db.Column and Column is used interchangeably. So when do you use one over the other?
id = db.Column(Integer(), primary_key=True)
vs
id = Column(Integer(), primary_key=True)
So I am making new flask app and noticed even in other projects that db.Column and Column is used interchangeably. So when do you use one over the other?
id = db.Column(Integer(), primary_key=True)
vs
id = Column(Integer(), primary_key=True)
It appears to be a convenience; there is no difference.
>>> from flask_sqlalchemy import SQLAlchemy
>>> db = SQLAlchemy()
>>> from sqlalchemy import Column
>>> db.Column is Column
True
In the docstring of the class SQLAlchemy you may see this comment:
This class also provides access to all the SQLAlchemy functions and classes from the
sqlalchemyandsqlalchemy.ormmodules.
The names are provided by a helper function _include_sqlalchemy that get's called in SQLAlchemy's initializer. A questionable design choice, perhaps, disregarding zen of Python #13 for no reason other than to reduce the number of import statements at the top of the module?