Each class represents a table in the database and the class attributes represents the columns of that table.
Requires SQLAlchemy:
SQLAlchemy uses Python classes to represent database tables and instances of those classes to represent rows in those tables.
ORM (Object-Relational Mapping)
!pip install Flask-SQLAlchemy
Example of use:
from app import db # Import the SQLAlchemy instance
from datetime import datetime
# Create an instance of the ESPDevice model
new_device = ESPDevice(DeviceID="1",
RegistrationTime=datetime.utcnow(),
LastActiveTime=datetime.utcnow())
# Add the new device to the session and commit it to the database
db.session.add(new_device)
db.session.commit()
Each class represents a table in the database and the class attributes represents the columns of that table.
Requires SQLAlchemy:
SQLAlchemy uses Python classes to represent database tables and instances of those classes to represent rows in those tables.
ORM (Object-Relational Mapping)
Example of use: