Skip to content

Models #18

Description

@Javimetro

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    DBAnything related to the DB

    Projects

    Status
    👀 In review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions