I'm using reflection on my database with sqlalchemy:
from sqlalchemy import create_engine
from sqlalchemt.ext.automap import automap_base
from sqlalchemy.orm import Session
Base = automap_base()
engine = create_engine('connection_string')
Base.prepare(engine, reflect=True)
User = Base.classes.users
session = Session(bind=engine)
and then, start doing some simple queries. But how do I know what type an attribute?
For example, I want to execute on registration date of a user datetime method or, on user's name some string method:
session.query.filter(User.RegisterDateTime.isoformat() == '2019-01-01T00:00:00')
session.query.filter(User.Id.startswith('f'))
So, how can I do that? Appreciate any help on reflcetion with SQLAlchemy.
Aucun commentaire:
Enregistrer un commentaire