Thank you for your help Mike I did not think about using the modulus.
So in sqlalchemy, tell me if I am wrong, the idea is to have the following request MyData.query.filter(MyData.date >= date1).filter(MyData.date <= date2).filter(func.mod(func.unix_timestamp(MyData.date) ,my_interval) == 0) If the computing time is still not acceptable. I will modify my table as you mentioned. Regards, Julien On Friday, June 16, 2017 at 11:14:02 AM UTC+8, Julien MOLINA wrote: > > Hi everybody, > > I am working on a project where I save every minutes (24h/24, 365 days a > year) physical data (temperature, pressure, flow) for an industrial > application in a MySQL Database thanks to sqlalchemy. > > I would like to extract the data to plot (pygal) the variables for a > specific period ( typically 1 day or 1 week ). However, I don't want to > select all the data but for example one every 10 minutes for daily plot, > one every hour for weekly plot. > > I try to use union or _or function inside filter but the computing times > are quite long. > > Do you have any idea of methods to do it as efficient as possible? > > Thank you very much for your help, > > Kind regards, > > Julien > -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.