An API for interacting with the Tahrir database
Project description
Tahrir-API
API for interacting with the Tahrir database. Based on the Tahrir database model written by Ralph Bean. There are two classes that can be used in this module. The first is the TahrirDatabase class located in tahrir_api.dbapi and the second is the database model located in tahrir_api.model. The TahrirDatabase class is a high level way to interact with the database. The model is used for a slightly more low level way of interacting with the database. It allows for custom interactions with the database without having to use the TahrirDatabase class.
Development
System Requirements
Before getting started, ensure your system meets the following requirements:
Software Requirements
Python: 3.9 or higher
Poetry: Latest version for dependency management
Database: PostgreSQL 9.6+ (recommended) or SQLite (basic development)
Git: For version control
Operating System Requirement
Fedora Linux: Latest non-EOL versions
Note: Other distributions may work, but are not officially supported. The maintainers may not be able to assist with platform-specific issues on non-Fedora systems.
Project Setup
Ensure that the necessary packages are installed:
$ sudo dnf install -y python3 python3-pip python3-devel poetry gcc krb5-devel git
Clone your fork to the local storage and make it your current working directory:
$ git clone https://github.com/fedora-infra/tahrir-api.git
$ cd tahrir-api
Create a virtual environment and activate it for installing project dependencies:
$ python3 -m venv venv
$ source venv/bin/activate
Install project dependencies:
(venv) $ poetry check
(venv) $ poetry install
Database Setup
Create a directory for storing the Tahrir database snapshot:
(venv) $ cd ..
(venv) $ mkdir badges-database
(venv) $ cd badges-database
Download and extract the Tahrir database snapshot:
(venv) $ wget https://infrastructure.fedoraproject.org/infra/db-dumps/tahrir.dump.xz
(venv) $ unxz tahrir.dump.xz
Create directories for persistent data and the database dump:
(venv) $ mkdir data dump
(venv) $ mv tahrir.dump dump/
Pull the PostgreSQL container image:
(venv) $ podman pull docker.io/library/postgres:15
Start the database container (be sure to rename the username and paths based on your development environment):
(venv) $ podman run \
--name badges-database \
--env POSTGRES_USER=badgesdb \
--env POSTGRES_PASSWORD=badgesdb \
--env POSTGRES_DB=badgesdb \
--env PGDATA=/var/lib/postgresql/data/pgdata \
--volume /home/username/Projects/badges-database/data:/var/lib/postgresql/data:Z \
--volume /home/username/Projects/badges-database/dump:/badgesdb:Z \
--publish 5432:5432 \
--restart unless-stopped \
--detach docker.io/library/postgres:15
Once the database container has started, log in to the interactive shell using the password to begin importing the extracted dump:
(venv )$ podman pull docker.io/library/postgres:15
(venv )$ podman run \
Execute the following SQL commands to create roles, load the database dump, and grant the needed access:
badgesdb=# create role "tahrir" with inherit nocreatedb nocreaterole noreplication nosuperuser valid until 'infinity' login password 'tahrir';
badgesdb=# create role "tahrir-readonly" with nocreatedb inherit nocreaterole noreplication nosuperuser valid until 'infinity' login password 'tahrir-readonly';
badgesdb=# \i badgesdb/tahrir.dump
badgesdb=# grant connect on database tahrir to "tahrir";
badgesdb=# grant all on all tables in schema public to "tahrir";
badgesdb=# grant all on all sequences in schema public to "tahrir";
badgesdb=# revoke create on schema public from public;
Exit out of the interactive shell and log back in using the newly created credentials:
(venv )$ podman exec -ti badges-database psql --username badgesdb --password
Verify the database setup:
(venv )$ tahrir=> \dt+
Run the tests
Download and install tox:
(venv) $ cd ./tahrir-api
(venv) $ sudo dnf install tox
Run the tests with tox:
(venv) $ tox
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tahrir_api-1.5.0.tar.gz.
File metadata
- Download URL: tahrir_api-1.5.0.tar.gz
- Upload date:
- Size: 48.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54d5f5093e0f17dce83e2fb4f73ccea16b0354080b3ab4abee881546affd61d8
|
|
| MD5 |
4e8a9efeb8b8e817560b0c4d924300ab
|
|
| BLAKE2b-256 |
8d843c7bdc982e8210f4ddc0d01dfec52af57154862b23173a1c8ca948ab5eb9
|
Provenance
The following attestation bundles were made for tahrir_api-1.5.0.tar.gz:
Publisher:
main.yml on fedora-infra/tahrir-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tahrir_api-1.5.0.tar.gz -
Subject digest:
54d5f5093e0f17dce83e2fb4f73ccea16b0354080b3ab4abee881546affd61d8 - Sigstore transparency entry: 2160599988
- Sigstore integration time:
-
Permalink:
fedora-infra/tahrir-api@cfc0c425665553002b43e6d7fa0d450f41742175 -
Branch / Tag:
refs/tags/1.5.0 - Owner: https://github.com/fedora-infra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@cfc0c425665553002b43e6d7fa0d450f41742175 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tahrir_api-1.5.0-py3-none-any.whl.
File metadata
- Download URL: tahrir_api-1.5.0-py3-none-any.whl
- Upload date:
- Size: 56.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
387604dd4ee2426a0ead09a1c15d3d34b29e1d8eb98cf01323c5e0380b155217
|
|
| MD5 |
0388b2a8f1b044fa9a5fd3ff290d77bf
|
|
| BLAKE2b-256 |
8a82601ebc7a3ad6e7897d9ccb20be3a6ec290b31d516b30e47dc1d324ede3e4
|
Provenance
The following attestation bundles were made for tahrir_api-1.5.0-py3-none-any.whl:
Publisher:
main.yml on fedora-infra/tahrir-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tahrir_api-1.5.0-py3-none-any.whl -
Subject digest:
387604dd4ee2426a0ead09a1c15d3d34b29e1d8eb98cf01323c5e0380b155217 - Sigstore transparency entry: 2160600077
- Sigstore integration time:
-
Permalink:
fedora-infra/tahrir-api@cfc0c425665553002b43e6d7fa0d450f41742175 -
Branch / Tag:
refs/tags/1.5.0 - Owner: https://github.com/fedora-infra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@cfc0c425665553002b43e6d7fa0d450f41742175 -
Trigger Event:
push
-
Statement type: