MySqlWebApp
===========
**MySqlWebApp** is a Flask-based Python framework that simplifies the development of MySQL-powered web applications. It provides a streamlined interface for connecting to a MySQL database, rendering templates, and executing queries dynamically via RESTful APIs.
Features
--------
- **Dynamic MySQL Configuration**: Configure MySQL database settings at runtime via a web interface.
- **Template Rendering**: Built-in support for rendering templates stored in the `templates` folder.
- **Query Execution API**: Execute MySQL queries dynamically through POST requests.
- **CRUD Operations**: Perform create, read, update, and delete operations programmatically.
- **RESTful Design**: Leverage Flask to expose endpoints for database interactions.
- **Environment Configuration**: Load sensitive credentials securely using environment variables.
Project Directory Structure
---------------------------
The project is organized as follows:
.. code-block:: text
MySqlWebApp/
├── MySqlWebApp/
│ ├── __init__.py # Package initialization
│ ├── MysqlApplication.py # Core application logic
│ └── templates/ # HTML templates
│ ├── home.html # Home page template
│ └── config_mysql.html # MySQL configuration template
├── setup.py # Setup script for packaging
├── README.rst # Project documentation
├── CHANGELOG.txt # Version history
├── MANIFEST.in # Additional file inclusion for packaging
├── LICENSE.txt # License details
├── pyproject.toml # Build configuration
└── requirements.txt # List of dependencies
Endpoints
---------
1. **`/`**: Displays the MySQL configuration page.
2. **`/home`**: Displays the home page.
3. **`/config_mysql`**: Accepts a POST request to configure MySQL connection details dynamically.
4. **`/execute_query`**: Accepts a POST request to execute MySQL queries or perform operations (e.g., insert, delete, update).
Installation
------------
1. Clone the repository:
.. code-block:: bash
git clone https://github.com/abuawaish/CRUD_App.git
cd MySqlWebApp
2. Install the required dependencies:
.. code-block:: bash
pip install -r requirements.txt
3. Set environment variables for database configuration:
.. code-block:: bash
export MYSQL_HOST=localhost
export MYSQL_USER=root
export MYSQL_PASSWORD=your password
export MYSQL_DB=mydatabase
export SECRET_KEY=your_secret_key
4. Run the application:
.. code-block:: bash
python -m MySqlWebApp.MysqlApplication
Usage
-----
**Running the Application**
To start the MySqlWebApp server, instantiate the `MysqlApplication` class and call its `execute` method. For example:
.. code-block:: python
from MySqlWebApp.MysqlApplication import MysqlApplication
if __name__ == "__main__":
app = MysqlApplication()
app.execute()
**This will:**
- Start a Flask server on `http://0.0.0.0:5001`.
- Serve endpoints for configuring and interacting with the MySQL database.
**Configuring MySQL**
1. Navigate to the root endpoint (`http://localhost:5001/`) to access the configuration page.
2. Enter the database details (host, username, password, database name) and click "Save".
3. Upon successful configuration, you will be redirected to the home page.
**Executing Queries**
Use the `/execute_query` endpoint to run SQL queries or perform operations. Example request:
- **POST Request Example**:
.. code-block:: json
{
"operation": "insert",
"table_name": "users",
"columns": "name, email",
"values": "'John Doe', 'john@example.com'"
}
- **Supported Operations**:
- `insert`: Insert data into a table.
- `delete`: Delete data from a table with a condition.
- `update`: Update data in a table with a condition.
- `fetch_data`: Fetch all data from a table.
- `show_tables`: List all tables in the database.
Dependencies
------------
The application requires the following dependencies (listed in `requirements.txt`):
- Flask: Web framework.
- Flask-MySQLdb: MySQL connector for Flask.
To install them, run:
.. code-block:: bash
pip install -r requirements.txt
Environment Variables
---------------------
- **MYSQL_HOST**: MySQL server hostname (default: `localhost`).
- **MYSQL_USER**: MySQL username (default: `root`).
- **MYSQL_PASSWORD**: MySQL password.
- **MYSQL_DB**: Default MySQL database name.
- **SECRET_KEY**: Flask secret key for session security.
Changelog
---------
Refer to `CHANGELOG.txt` for the complete version history of the project.
License
-------
This project is licensed under the MIT License. See `LICENSE.txt` for full details.
Contributing
------------
Contributions are welcome! To contribute:
1. Fork this repository.
2. Create a new branch for your feature or bugfix.
3. Submit a pull request with a clear description of your changes.
Contact
-------
For questions or feedback, contact:
- Email: abuawaish7@gmail.com
- GitHub: https://github.com/abuawaish/CRUD_App
CHANGELOG
=========
Version 1.1 (2025-01-27)
---------------------------
- Initial release of MySqlWebApp.
- Added dynamic MySQL configuration through a web interface.
- Implemented template rendering for `config_mysql.html` and `home.html`.
- Developed `/execute_query` endpoint for executing MySQL queries.
- Supported CRUD operations: insert, delete, update, fetch_data.
- Enabled secure database connection using environment variables.
- Provided RESTFul API design for interaction with MySQL.
Raw data
{
"_id": null,
"home_page": "https://github.com/abuawaish/Crud_app",
"name": "MySqlWebApp",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "Web App",
"author": "Abu Awaish",
"author_email": "abuawaish7@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/65/23/fbb3f7dee7d15efea34900d5e33b0a6128ffbad7a2b5e5fa3eed326214f5/mysqlwebapp-1.1.tar.gz",
"platform": null,
"description": "MySqlWebApp\r\n===========\r\n\r\n**MySqlWebApp** is a Flask-based Python framework that simplifies the development of MySQL-powered web applications. It provides a streamlined interface for connecting to a MySQL database, rendering templates, and executing queries dynamically via RESTful APIs.\r\n\r\nFeatures\r\n--------\r\n- **Dynamic MySQL Configuration**: Configure MySQL database settings at runtime via a web interface.\r\n- **Template Rendering**: Built-in support for rendering templates stored in the `templates` folder.\r\n- **Query Execution API**: Execute MySQL queries dynamically through POST requests.\r\n- **CRUD Operations**: Perform create, read, update, and delete operations programmatically.\r\n- **RESTful Design**: Leverage Flask to expose endpoints for database interactions.\r\n- **Environment Configuration**: Load sensitive credentials securely using environment variables.\r\n\r\nProject Directory Structure\r\n---------------------------\r\nThe project is organized as follows:\r\n\r\n.. code-block:: text\r\n\r\n MySqlWebApp/\r\n \u00e2\u201d\u0153\u00e2\u201d\u20ac\u00e2\u201d\u20ac MySqlWebApp/\r\n \u00e2\u201d\u201a \u00e2\u201d\u0153\u00e2\u201d\u20ac\u00e2\u201d\u20ac __init__.py # Package initialization\r\n \u00e2\u201d\u201a \u00e2\u201d\u0153\u00e2\u201d\u20ac\u00e2\u201d\u20ac MysqlApplication.py # Core application logic\r\n \u00e2\u201d\u201a \u00e2\u201d\u201d\u00e2\u201d\u20ac\u00e2\u201d\u20ac templates/ # HTML templates\r\n \u00e2\u201d\u201a \u00e2\u201d\u0153\u00e2\u201d\u20ac\u00e2\u201d\u20ac home.html # Home page template\r\n \u00e2\u201d\u201a \u00e2\u201d\u201d\u00e2\u201d\u20ac\u00e2\u201d\u20ac config_mysql.html # MySQL configuration template\r\n \u00e2\u201d\u0153\u00e2\u201d\u20ac\u00e2\u201d\u20ac setup.py # Setup script for packaging\r\n \u00e2\u201d\u0153\u00e2\u201d\u20ac\u00e2\u201d\u20ac README.rst # Project documentation\r\n \u00e2\u201d\u0153\u00e2\u201d\u20ac\u00e2\u201d\u20ac CHANGELOG.txt # Version history\r\n \u00e2\u201d\u0153\u00e2\u201d\u20ac\u00e2\u201d\u20ac MANIFEST.in # Additional file inclusion for packaging\r\n \u00e2\u201d\u0153\u00e2\u201d\u20ac\u00e2\u201d\u20ac LICENSE.txt # License details\r\n \u00e2\u201d\u0153\u00e2\u201d\u20ac\u00e2\u201d\u20ac pyproject.toml # Build configuration\r\n \u00e2\u201d\u201d\u00e2\u201d\u20ac\u00e2\u201d\u20ac requirements.txt # List of dependencies\r\n\r\n\r\nEndpoints\r\n---------\r\n1. **`/`**: Displays the MySQL configuration page.\r\n2. **`/home`**: Displays the home page.\r\n3. **`/config_mysql`**: Accepts a POST request to configure MySQL connection details dynamically.\r\n4. **`/execute_query`**: Accepts a POST request to execute MySQL queries or perform operations (e.g., insert, delete, update).\r\n\r\nInstallation\r\n------------\r\n1. Clone the repository:\r\n\r\n .. code-block:: bash\r\n\r\n git clone https://github.com/abuawaish/CRUD_App.git\r\n cd MySqlWebApp\r\n\r\n2. Install the required dependencies:\r\n\r\n .. code-block:: bash\r\n\r\n pip install -r requirements.txt\r\n\r\n3. Set environment variables for database configuration:\r\n\r\n .. code-block:: bash\r\n\r\n export MYSQL_HOST=localhost\r\n export MYSQL_USER=root\r\n export MYSQL_PASSWORD=your password\r\n export MYSQL_DB=mydatabase\r\n export SECRET_KEY=your_secret_key\r\n\r\n4. Run the application:\r\n\r\n .. code-block:: bash\r\n\r\n python -m MySqlWebApp.MysqlApplication\r\n\r\nUsage\r\n-----\r\n\r\n**Running the Application**\r\n\r\nTo start the MySqlWebApp server, instantiate the `MysqlApplication` class and call its `execute` method. For example:\r\n\r\n.. code-block:: python\r\n\r\n from MySqlWebApp.MysqlApplication import MysqlApplication\r\n\r\n if __name__ == \"__main__\":\r\n app = MysqlApplication()\r\n app.execute()\r\n\r\n**This will:**\r\n\r\n- Start a Flask server on `http://0.0.0.0:5001`.\r\n- Serve endpoints for configuring and interacting with the MySQL database.\r\n\r\n\r\n**Configuring MySQL**\r\n\r\n1. Navigate to the root endpoint (`http://localhost:5001/`) to access the configuration page.\r\n2. Enter the database details (host, username, password, database name) and click \"Save\".\r\n3. Upon successful configuration, you will be redirected to the home page.\r\n\r\n**Executing Queries**\r\n\r\nUse the `/execute_query` endpoint to run SQL queries or perform operations. Example request:\r\n\r\n- **POST Request Example**:\r\n\r\n .. code-block:: json\r\n\r\n {\r\n \"operation\": \"insert\",\r\n \"table_name\": \"users\",\r\n \"columns\": \"name, email\",\r\n \"values\": \"'John Doe', 'john@example.com'\"\r\n }\r\n\r\n- **Supported Operations**:\r\n - `insert`: Insert data into a table.\r\n - `delete`: Delete data from a table with a condition.\r\n - `update`: Update data in a table with a condition.\r\n - `fetch_data`: Fetch all data from a table.\r\n - `show_tables`: List all tables in the database.\r\n\r\nDependencies\r\n------------\r\nThe application requires the following dependencies (listed in `requirements.txt`):\r\n\r\n- Flask: Web framework.\r\n- Flask-MySQLdb: MySQL connector for Flask.\r\n\r\nTo install them, run:\r\n\r\n.. code-block:: bash\r\n\r\n pip install -r requirements.txt\r\n\r\nEnvironment Variables\r\n---------------------\r\n- **MYSQL_HOST**: MySQL server hostname (default: `localhost`).\r\n- **MYSQL_USER**: MySQL username (default: `root`).\r\n- **MYSQL_PASSWORD**: MySQL password.\r\n- **MYSQL_DB**: Default MySQL database name.\r\n- **SECRET_KEY**: Flask secret key for session security.\r\n\r\nChangelog\r\n---------\r\nRefer to `CHANGELOG.txt` for the complete version history of the project.\r\n\r\nLicense\r\n-------\r\nThis project is licensed under the MIT License. See `LICENSE.txt` for full details.\r\n\r\nContributing\r\n------------\r\nContributions are welcome! To contribute:\r\n\r\n1. Fork this repository.\r\n2. Create a new branch for your feature or bugfix.\r\n3. Submit a pull request with a clear description of your changes.\r\n\r\nContact\r\n-------\r\nFor questions or feedback, contact:\r\n\r\n- Email: abuawaish7@gmail.com\r\n- GitHub: https://github.com/abuawaish/CRUD_App\r\n\r\n\r\nCHANGELOG\r\n=========\r\n\r\nVersion 1.1 (2025-01-27)\r\n---------------------------\r\n\r\n- Initial release of MySqlWebApp.\r\n- Added dynamic MySQL configuration through a web interface.\r\n- Implemented template rendering for `config_mysql.html` and `home.html`.\r\n- Developed `/execute_query` endpoint for executing MySQL queries.\r\n- Supported CRUD operations: insert, delete, update, fetch_data.\r\n- Enabled secure database connection using environment variables.\r\n- Provided RESTFul API design for interaction with MySQL.\r\n\r\n\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python package for building dynamic MySQL-powered web applications with template support",
"version": "1.1",
"project_urls": {
"Homepage": "https://github.com/abuawaish/Crud_app"
},
"split_keywords": [
"web",
"app"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d728666fbb2dd7c8bfcfab51a5cb6e8d878ef8afce0d8900e6b6e2e0a4985d91",
"md5": "440045a952f6f4c862a6f3d767d69915",
"sha256": "eccf817fd7c7d6ceb70e31ac42765e3eace11c4bc0711c300dfda04923876853"
},
"downloads": -1,
"filename": "MySqlWebApp-1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "440045a952f6f4c862a6f3d767d69915",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 6262,
"upload_time": "2025-01-26T20:20:49",
"upload_time_iso_8601": "2025-01-26T20:20:49.343324Z",
"url": "https://files.pythonhosted.org/packages/d7/28/666fbb2dd7c8bfcfab51a5cb6e8d878ef8afce0d8900e6b6e2e0a4985d91/MySqlWebApp-1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6523fbb3f7dee7d15efea34900d5e33b0a6128ffbad7a2b5e5fa3eed326214f5",
"md5": "2c7c1b7b3d99278938c5fe11307be0ee",
"sha256": "ce26cd34445d1402369c433c67b0bbe36c8f17452435a1795c635d135ca0621e"
},
"downloads": -1,
"filename": "mysqlwebapp-1.1.tar.gz",
"has_sig": false,
"md5_digest": "2c7c1b7b3d99278938c5fe11307be0ee",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 9495,
"upload_time": "2025-01-26T20:20:50",
"upload_time_iso_8601": "2025-01-26T20:20:50.682719Z",
"url": "https://files.pythonhosted.org/packages/65/23/fbb3f7dee7d15efea34900d5e33b0a6128ffbad7a2b5e5fa3eed326214f5/mysqlwebapp-1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-26 20:20:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "abuawaish",
"github_project": "Crud_app",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "Flask",
"specs": []
},
{
"name": "Flask-MySQLdb",
"specs": []
},
{
"name": "gunicorn",
"specs": []
}
],
"lcname": "mysqlwebapp"
}