pip install pyyaml
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
python databaseserver.py
The server will start and listen on the port specified in config.yml
(default: 8000).
The server's behavior is controlled via the config.yml
file. Here’s what each section means:
port
: The port on which the server will listen for incoming requests.file_path
: The file where the database is stored. The file should be accessible and writable.log_file
: The file where logs will be written. Ensure this file is writable.Description: Retrieves the entire dataset excluding the history.
Response:
Status Code: 200 OK
Content-Type: application/json
Body:
{
"data": [...]
}
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
},
...
]
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",
...
}
]
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"
}
Description: Rolls back the last change made to the database.
Response:
Status Code: 200 OK
Content-Type: application/json
Body:
{
"message": "Rollback successful"
}
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"
}
Description: Deletes an entry from the database.
Response:
Status Code: 200 OK
Content-Type: application/json
Body:
{
"message": "Data deleted successfully"
}
The server logs its activity to the file specified in config.yml
under logging.log_file
. This includes:
To interact with the DictatorDatabase server, use HTTP methods to communicate with the following endpoints:
Example using curl
:
curl -X GET http://localhost:8000/data
curl -X POST http://localhost:8000/data -H "Content-Type: application/json" -d '{"key": "value"}'
curl -X GET http://localhost:8000/search/example
curl -X PUT http://localhost:8000/data/0 -H "Content-Type: application/json" -d '{"key": "new_value"}'
curl -X DELETE http://localhost:8000/data/0
/data
endpoint to populate user interfaces or generate reports.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.