Mercurial Hosting > traffic-intelligence
diff python/metadata.py @ 1004:75601be6019f
work on process
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sun, 03 Jun 2018 00:21:18 -0400 |
parents | b50145235f9e |
children |
line wrap: on
line diff
--- a/python/metadata.py Fri Jun 01 17:19:31 2018 -0400 +++ b/python/metadata.py Sun Jun 03 00:21:18 2018 -0400 @@ -350,12 +350,17 @@ Session = sessionmaker(bind=engine) return Session() -def getSite(session, siteId): +def getSite(session, siteId = None, name = None, description = None): 'Returns the site(s) matching the index or the name' - if str.isdigit(siteId): + if siteId is not None: return session.query(Site).filter(Site.idx == int(siteId)).all() + elif name is not None: + return session.query(Site).filter(Site.description.like('%'+name+'%')).all() + elif description is not None: + return session.query(Site).filter(Site.description.like('%'+description+'%')).all() else: - return session.query(Site).filter(Site.description.like('%'+siteId+'%')).all() + print('No siteId, name or description have been provided to the function') + return [] def getCameraView(session, viewId): 'Returns the site(s) matching the index' @@ -405,3 +410,6 @@ startTime += duration session.add_all(videoSequences) session.commit() + +# management +# TODO need to be able to copy everything from a site from one sqlite to another, and delete everything attached to a site