Here is how I define the query:

_query = self.session.query(self.model.type, 
func.sum(case(value=self.model.final_status, whens={'SUCCESS': 
(self.model.end_time - self.model.start_time).total_seconds()}, else_=None)


Here the end_time and start_time are columns of DateTime type.


Here is the error I got.  Desperately need help here, and really appreciate any 
suggestions! 


Error message:



   - File "/usr/local/lib/python2.7/site-packages/flask/app.py", line *1997*, 
in __call__
   
   return self.wsgi_app(environ, start_response)
   
   - File "/usr/local/lib/python2.7/site-packages/flask/app.py", line *1985*, 
   in wsgi_app
   
   response = self.handle_exception(e)
   
   - File "/usr/local/lib/python2.7/site-packages/flask/app.py", line *1540*, 
   in handle_exception
   
   reraise(exc_type, exc_value, tb)
   
   - File "/usr/local/lib/python2.7/site-packages/flask/app.py", line *1982*, 
   in wsgi_app
   
   response = self.full_dispatch_request()
   
   - File "/usr/local/lib/python2.7/site-packages/flask/app.py", line *1614*, 
   in full_dispatch_request
   
   rv = self.handle_user_exception(e)
   
   - File "/usr/local/lib/python2.7/site-packages/flask/app.py", line *1517*, 
   in handle_user_exception
   
   reraise(exc_type, exc_value, tb)
   
   - File "/usr/local/lib/python2.7/site-packages/flask/app.py", line *1612*, 
   in full_dispatch_request
   
   rv = self.dispatch_request()
   
   - File "/usr/local/lib/python2.7/site-packages/flask/app.py", line *1598*, 
   in dispatch_request
   
   return self.view_functions[rule.endpoint](**req.view_args)
   
   - File "/usr/local/lib/python2.7/site-packages/flask_admin/base.py", 
   line *69*, in inner
   
   return self._run_view(f, *args, **kwargs)
   
   - File "/usr/local/lib/python2.7/site-packages/flask_admin/base.py", 
   line *368*, in _run_view
   
   return fn(self, *args, **kwargs)
   
   - File "/usr/local/lib/python2.7/site-packages/flask_admin/model/base.py", 
   line *1882*, in index_view
   
   view_args.search, view_args.filters, page_size=page_size)
   
   - File 
   "/usr/local/lib/python2.7/site-packages/flask_admin/contrib/sqla/view.py", 
   line *997*, in get_list
   
   query = self.get_query()
   
   - File "/app/src/main/python/hermes_reporter/admin.py", line *344*, in 
   get_query
   
   whens={'SUCCESS': (_model.updated_on - _model.created_on).total_seconds()},
   
   - File 
   "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", 
   line *682*, in __getattr__
   
   key)
   
   
AttributeError: Neither 'BinaryExpression' object nor 'Comparator' object 
has an attribute 'total_seconds'

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to