title: SQL Alchemy: AttributeError: type object 'events' has no attribute 'query'
body: <p>I'm trying to delete events in the database that already happened. My script is as follows.</p>
  
  <p>On the line with **, I get an error</p>
  
  <pre><code>AttributeError: type object 'events' has no attribute 'query'
  </code></pre>
  
  <p>Does anyone know how to fix this? Thanks!</p>
  
  <pre><code>Base = automap_base()
  
  # engine, suppose it has two tables 'user' and 'address' set up
  engine = create_engine("DB_URL")
  
  # reflect the tables
  Base.prepare(engine, reflect=True)
  
  # mapped classes are now created with names by default
  # matching that of the table name.
  Event = Base.classes.events
  User = Base.classes.users
  
  **events = Event.query.filter(end_time &lt; datetime.now())**
  session = Session(engine)
  session.delete(events)
  session.commit()
  </code></pre>