Skip to content
 
 

Repository files navigation

registration

The goal of this assignment is to build a simple command-line user registration system using Python and MySQL. You will gain hands-on experience connecting to a database, executing SQL CRUD operations (Create, Read, Update, Delete), generating synthetic data, and designing a user-friendly command-line interface.

Problem set description document: Document Link.

Nora's documentation:

📖 Usage Guide

Run the Interactive Menu

python3 main.py

This will launch the interactive CLI menu for managing users.

If you're interested in understanding the setup and testing process step-by-step, continue reading below.

Environment Setup

✅ Note: The database is already configured. The steps below are for demonstration purposes only — you do NOT need to repeat them.

🐳 1. Start MySQL Using Docker

setup db: 
docker run -d \
  --name mysql-server \
  -e MYSQL_ROOT_PASSWORD=root123 \
  -e MYSQL_DATABASE=user_registration \
  -p 3306:3306 \
  mysql:8.0
  • verify
docker ps 

📦 2. Install Dependencies

pip install mysql-connector-python PyYAML Faker rich

and

pip install bcrypt

🧪 Testing Individual Components (Optional)

  • Note: this is only to test classes one by one, you also do not need to do it unless you want to to make sure everything is fine (it's already tested)

Test db_connection.py :

python3 -c "from db_connection import get_connection, close_connection; conn = get_connection(); close_connection(conn) if conn else None"

create db and tables:

python3 create_database_and_table.py

create first user:

Test create user with invalid user name 
python3 -c "from create_user import create_user; create_user('nora', 'test@test.com', 'pass123', 'bos', 'Company', 'Dev')"

Read all users

python3 read_users.py

Update user interactive:

python3 update_user.py

or not interactive:

python3 -c "from update_user import update_user_password; update_user_password('nora', 'newpassword123')"

delete user (interactive)

python3 delete_user.py

now ill create another user just to continue working (not interactive)

python3 -c "from create_user import create_user; create_user('ali_smith', 'ali@example.com', 'password456', 'San Francisco', 'Tech Solutions', 'Data Scientist')"

Now let's create synthatic 1000 user :

python3 populate_users.py

let's read them :

python3 read_users.py

and here let's count them

docker exec mysql-server mysql -uroot -proot123 user_registration -e "SELECT COUNT(*) as total_users FROM users;"

About

The goal of this assignment is to build a simple command-line user registration system using Python and MySQL. You will gain hands-on experience connecting to a database, executing SQL CRUD operations (Create, Read, Update, Delete), generating synthetic data, and designing a user-friendly command-line interface.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages