diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2019-04-27 00:25:09 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2019-04-27 00:25:09 +0200 |
| commit | a0e583ee4eebe37db4011a99b65d0d60db324054 (patch) | |
| tree | 51845a417f2998719160f7815d3f1f4fe8e89f20 /check/app/models/sql_factory.py | |
| parent | 8e9214f5d4d2a725eecdb11368451d99168ae240 (diff) | |
api now fetches url
Diffstat (limited to 'check/app/models/sql_factory.py')
| -rw-r--r-- | check/app/models/sql_factory.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/check/app/models/sql_factory.py b/check/app/models/sql_factory.py index 5433b67..ad27f62 100644 --- a/check/app/models/sql_factory.py +++ b/check/app/models/sql_factory.py @@ -32,15 +32,16 @@ class FileTable(Base): __tablename__ = 'files' id = Column(Integer, primary_key=True) sha256 = Column(String(64, convert_unicode=True), nullable=False) - url = Column(String(255, convert_unicode=True), nullable=False) phash = Column(BigInteger, nullable=False, index=True) ext = Column(String(4, convert_unicode=True), nullable=False) + url = Column(String(255, convert_unicode=True), nullable=False) def toJSON(self): return { 'id': self.id, 'sha256': self.sha256, 'phash': self.phash, 'ext': self.ext, + 'url': self.url, } Base.metadata.create_all(engine) @@ -56,7 +57,7 @@ def search_by_phash(phash, threshold=6, limit=1): LIMIT :limit """ matches = connection.execute(text(cmd), phash=phash, threshold=threshold, limit=limit).fetchall() - keys = ('id', 'sha256', 'phash', 'ext', 'score') + keys = ('id', 'sha256', 'phash', 'ext', 'url', 'score') results = [ dict(zip(keys, values)) for values in matches ] return results @@ -65,7 +66,7 @@ def search_by_hash(hash): match = session.query(FileTable).filter(FileTable.sha256 == hash) return match.first() -def add_phash(sha256, phash, ext, url): +def add_phash(sha256=None, phash=None, ext=None, url=None): """Add a file to the table""" rec = FileTable(sha256=sha256, phash=phash, ext=ext, url=url) session = Session() |
