How to make a filter query with flask?

import json
from sqlalchemy import Float, Identity, create_engine
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

engine = create_engine(
    'sqlite:///dati.db', connect_args={"check_same_thread": False}, echo=True,)

Session = sessionmaker(bind=engine)
session = Session()

Base = declarative_base()

class Periodic_element(Base):

    __tablename__ = "dati"

    id = Column(Integer, Identity(start=1, cycle=True),
                primary_key=True, nullable=True)
    name = Column(String)
    weight = Column(Float)
    symbol = Column(String)

    def __init__(self, id, name, weight, symbol): = None = name
        self.weight = weight
        self.symbol = symbol

    def __repr__(self):
        return '' % (

    def toJson(self):
        response = {}
        for column in self.__table__.columns.keys():
            response[column] = getattr(self, column)
        return response

def add_record(id, name, symbol, weight):
    record = Periodic_element(id=None, name=name, symbol=symbol, weight=weight)

def serve_record():
    records = session.query(Periodic_element).all()

    return json.dumps([record.toJson() for record in records])


if __name__ == "__main__":
    add_record(1, 'foo', 'bar', 12)