diff options
author | Joris | 2024-06-02 14:38:13 +0200 |
---|---|---|
committer | Joris | 2024-06-02 14:38:22 +0200 |
commit | 1019ea1ed341e3a7769c046aa0be5764789360b6 (patch) | |
tree | 1a0d8a4f00cff252d661c42fc23ed4c19795da6f /src/db.py | |
parent | e8da9790dc6d55cd2e8883322cdf9a7bf5b4f5b7 (diff) |
Migrate to Rust and Hyper
With sanic, downloading a file locally is around ten times slower than
with Rust and hyper.
Maybe `pypy` could have helped, but I didn’t succeed to set it up
quickly with the dependencies.
Diffstat (limited to 'src/db.py')
-rw-r--r-- | src/db.py | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/src/db.py b/src/db.py deleted file mode 100644 index a6e29fd..0000000 --- a/src/db.py +++ /dev/null @@ -1,24 +0,0 @@ -import secrets - -def insert_file(conn, filename: str, expiration_days: int, content_length: int): - cur = conn.cursor() - file_id = secrets.token_urlsafe() - cur.execute( - 'INSERT INTO files(id, filename, created, expires, content_length) VALUES(?, ?, datetime(), datetime(datetime(), ?), ?)', - (file_id, filename, f'+{expiration_days} days', content_length) - ) - conn.commit() - return file_id - -def get_file(conn, file_id: str): - cur = conn.cursor() - res = cur.execute( - ''' - SELECT filename, expires, content_length - FROM files - WHERE id = ? AND expires > datetime() - ''', - (file_id,) - ) - return res.fetchone() - |