Skip to content

Anticoder03/python-database-mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask MySQL CRUD Application

A simple and clean CRUD (Create, Read, Update, Delete) application built using:

  • Python
  • Flask
  • MySQL
  • Tailwind CSS
  • Jinja Templates

This project demonstrates how to connect Python to MySQL and handle CRUD operations through a web-based UI.


🚀 Features

  • Add new items
  • Edit existing items
  • Delete items
  • Display items in a table
  • Fully functional MySQL connectivity
  • Modern UI with TailwindCSS

📁 Project Structure


flask-mysql-crud/
│── app.py
│── db.py
│── config.py  (ignored in Git)
│── config.example.py
│── requirements.txt
│── templates/
│    ├── base.html
│    ├── index.html
│    ├── add.html
│    └── edit.html



🛠️ Installation & Setup

1. Clone the Repository

git clone https://github.com/your-username/flask-mysql-crud.git
cd flask-mysql-crud

2. Install Required Packages

pip install -r requirements.txt

3. Create MySQL Database

Log in to MySQL and run:

CREATE DATABASE flask_crud;
USE flask_crud;

CREATE TABLE items (
    id INT PRIMARY KEY AUTO_INCREMENT,
    name VARCHAR(255),
    price DECIMAL(10,2)
);

4. Configure MySQL Connection

Rename:

config.example.py → config.py

Edit config.py:

HOST = "localhost"
USER = "root"
PASSWORD = ""
DATABASE = "flask_crud"

5. Run the Application

python app.py

Visit:

http://127.0.0.1:5000/

📌 CRUD Operations Overview

Operation Description
CREATE Add item via /add
READ List all items on homepage
UPDATE Edit item via /edit/<id>
DELETE Remove item via /delete/<id>

🧰 Tech Stack

  • Backend: Python, Flask
  • Database: MySQL
  • Frontend: HTML, TailwindCSS
  • Template Engine: Jinja2

📜 License

This project is open-source and free to use.


⭐ Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published