Follow these steps to set up the project and run the code on your local machine.
Ensure the following are installed:
- Python 3.7 or later
- PostgreSQL
pip
(Python package manager)
Also, you need to ensure that you have a server.log file inside logs/ directory.
sudo apt update
sudo apt install postgresql postgresql-contrib
brew install postgresql
- Download PostgreSQL from the official website.
- Run the installer and follow the setup wizard.
sudo service postgresql start
- Open the PostgreSQL shell:
sudo -u postgres psql
- Run the following commands:
CREATE USER myuser WITH PASSWORD 'mypassword'; CREATE DATABASE mydatabase; GRANT ALL PRIVILEGES ON DATABASE mydatabase TO myuser;
- Exit the PostgreSQL shell:
\q
git clone https://github.com/your-repository/serverinfo-sorting.git
cd serverinfo-sorting
Install all required libraries using pip
:
pip install sortedcontainers psycopg2-binary loguru
Update the PostgreSQL connection settings in the script:
DB_HOST = "localhost"
DB_PORT = "5432"
DB_NAME = "mydatabase"
DB_USER = "myuser"
DB_PASSWORD = "mypassword"
Execute the script to verify functionality:
./run.sh