StalinSoft

DictatorDatabase User Manual


Table of Contents


Getting Started

  1. Install Dependencies: Ensure you have Python 3.12 or later and install the required Python packages:
    pip install pyyaml
  2. Configure the Server: Create a config.yml file in the same directory as the server script with the following content:
    server:
      port: 8000
    
    database:
      file_path: database.ddb
    
    logging:
      log_file: server.log
    
  3. Run the Server:
    python databaseserver.py
    The server will start and listen on the port specified in config.yml (default: 8000).

Configuration

The server's behavior is controlled via the config.yml file. Here’s what each section means:

API Endpoints

GET /data

Description: Retrieves the entire dataset excluding the history.

Response:
Status Code: 200 OK
Content-Type: application/json
Body:

{
  "data": [...]
}

GET /history

Description: Retrieves the history of changes made to the database.

Response:
Status Code: 200 OK
Content-Type: application/json
Body:

[
  {
    "action": "add",
    "data": {...},
    "timestamp": "ISO8601_TIMESTAMP",
    "old_data": null
  },
  ...
]

GET /search/<search_terms>

Description: Searches the database for entries matching the provided search terms.

Response:
Status Code: 200 OK
Content-Type: application/json
Body:

[
  {
    "matching_key": "matching_value",
    ...
  }
]

POST /data

Description: Adds a new entry to the database.

Request Body:
Content-Type: application/json
Body:

{
  "key": "value",
  ...
}

Response:
Status Code: 200 OK
Content-Type: application/json
Body:

{
  "message": "Data added successfully"
}

POST /data/rollback

Description: Rolls back the last change made to the database.

Response:
Status Code: 200 OK
Content-Type: application/json
Body:

{
  "message": "Rollback successful"
}

PUT /data/<index>

Description: Updates an existing entry in the database.

Request Body:
Content-Type: application/json
Body:

{
  "key": "new_value",
  ...
}

Response:
Status Code: 200 OK
Content-Type: application/json
Body:

{
  "message": "Data updated successfully"
}

DELETE /data/<index>

Description: Deletes an entry from the database.

Response:
Status Code: 200 OK
Content-Type: application/json
Body:

{
  "message": "Data deleted successfully"
}

Error Handling

Logging

The server logs its activity to the file specified in config.yml under logging.log_file. This includes:

Integration Guide

HTTP Communication

To interact with the DictatorDatabase server, use HTTP methods to communicate with the following endpoints:

Example using curl:

Example Use Cases

This manual should help you understand and use DictatorDatabase effectively. For any issues or further assistance, refer to the server logs or contact the support team.