From 33d203d65d50d03b3a08573a37ee835fa040ff73 Mon Sep 17 00:00:00 2001 From: dvch162 Date: Sun, 11 May 2025 22:43:48 +0300 Subject: [PATCH] Add project README with setup instructions --- README.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..900a2d33 --- /dev/null +++ b/README.md @@ -0,0 +1,82 @@ +Django + MySQL Setup (Using Docker) +This project sets up a Django application connected to a MySQL database using Docker. No local MySQL installation is required. + +Quick Start +1. Run MySQL via Docker +Use the following command in your terminal: + +docker run --name mysql +-e MYSQL_ROOT_PASSWORD=password123 +-e MYSQL_DATABASE=elderco +-p 3307:3306 +-d mysql:8 + +What this does: + +Starts a MySQL container named mysql + +Sets root password to password123 + +Creates a database named elderco + +Exposes container’s port 3306 on host’s port 3307 + +2. Install Python Dependencies +Make sure you have a virtual environment activated, then run: + +pip install mysql-connector-python + +3. Configure Django Database Settings +In your Django settings.py file, set the following: + +DATABASES = { +'default': { +'ENGINE': 'mysql.connector.django', +'NAME': 'elderco', +'USER': 'root', +'PASSWORD': 'password123', +'HOST': '127.0.0.1', +'PORT': '3307', +} +} + +4. Apply Migrations and Start Django +Run the following commands: + +python manage.py migrate +python manage.py runserver + +Then visit http://127.0.0.1:8000 in your browser. + +Optional: Access MySQL CLI in Container +To access the database shell: + +docker exec -it mysql mysql -u root -p + +Then enter the password password123. You can use SQL commands like: + +SHOW DATABASES; +USE elderco; + +Stop and Remove the MySQL Container +To stop and clean up the container: + +docker stop mysql +docker rm mysql + +Project Structure +your_project/ +├── dcrm/ +│ └── settings.py +├── website/ +├── manage.py +└── README.md + +Requirements: + +Python 3.x + +pip + +Docker +