query="SELECT a.* FROM updates a INNER JOIN ( SELECT MAX(file_version) file_version, filename FROM updates WHERE {} < {} GROUP BY filename) b ON a.file_version = b.file_version"
ifmethodis"timestamp":
query+=" ORDER BY a.timestamp DESC"
elifmethodis"file_hash":
query="SELECT * FROM updates WHERE {} = '{}'"
cur.execute("SELECT a.* FROM updates a INNER JOIN ( SELECT MAX(file_version) file_version, filename FROM updates WHERE {} < {} GROUP BY filename) b ON a.file_version = b.file_version;".format(