asgi-log-to-sqlite
ASGI middleware for logging traffic to a SQLite database
See Logging to SQLite using ASGI middleware for background on this project.
Installation
pip install asgi-log-to-sqlite
Usage
from asgi_log_to_sqlite import AsgiLogToSqlite
from my_asgi_app import app
app = AsgiLogToSqlite(app, "/tmp/log.db")
Requests to your ASGI app will now be logged to the SQLite database file at /tmp/log.db.
Schema
The database used to log requests has one key table - requests - and 6 lookup tables: paths, user_agents, referers, accept_languages, content_types and query_strings.
The full schema is as follows:
CREATE TABLE [paths] (
[id] INTEGER PRIMARY KEY,
[name] TEXT
);
CREATE UNIQUE INDEX idx_paths_name
ON paths (name);
CREATE TABLE [user_agents] (
[id] INTEGER PRIMARY KEY,
[name] TEXT
);
CREATE UNIQUE INDEX idx_user_agents_name
ON user_agents (name);
CREATE TABLE [referers] (
[id] INTEGER PRIMARY KEY,
[name] TEXT
);
CREATE UNIQUE INDEX idx_referers_name
ON referers (name);
CREATE TABLE [accept_languages] (
[id] INTEGER PRIMARY KEY,
[name] TEXT
);
CREATE UNIQUE INDEX idx_accept_languages_name
ON accept_languages (name);
CREATE TABLE [content_types] (
[id] INTEGER PRIMARY KEY,
[name] TEXT
);
CREATE UNIQUE INDEX idx_content_types_name
ON content_types (name);
CREATE TABLE [query_strings] (
[id] INTEGER PRIMARY KEY,
[name] TEXT
);
CREATE UNIQUE INDEX idx_query_strings_name
ON query_strings (name);
CREATE TABLE [requests] (
[start] FLOAT,
[method] TEXT,
[path] INTEGER REFERENCES [paths]([id]),
[query_string] INTEGER REFERENCES [query_strings]([id]),
[user_agent] INTEGER REFERENCES [user_agents]([id]),
[referer] INTEGER REFERENCES [referers]([id]),
[accept_language] INTEGER REFERENCES [accept_languages]([id]),
[http_status] INTEGER,
[content_type] INTEGER REFERENCES [content_types]([id]),
[client_ip] TEXT,
[duration] FLOAT,
[body_size] INTEGER
);
Metadata
Release files for asgi-log-to-sqlite 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asgi_log_to_sqlite-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for asgi_log_to_sqlite-0.1.1-py3-none-any.whl |
Release files / asgi_log_to_sqlite-0.1.1-py3-none-any.whl
| Download URL | asgi_log_to_sqlite-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c8a99b2c755389fc110a5e1c63247adaa82b93cf78cbaad449b5b341e1257d1c
|
|
BLAKE2b-256 checksum How to use checksums |
755c1df94bafebe64fc54f223978fb4f189fad8f8ffe7a8e913c24881eb2263d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10
|
Security for asgi-log-to-sqlite 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.