PyAwaish


NamePyAwaish JSON
Version 1.6.3 PyPI version JSON
download
home_pagehttps://github.com/abuawaish
SummaryA Python package for building dynamic MySQL-powered web applications with template support
upload_time2025-02-20 06:42:06
maintainerNone
docs_urlNone
authorAbu Awaish
requires_python>=3.6
licenseMIT
keywords web application flask mysql dynamic templates
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            PyAwaish
===========

**PyAwaish** 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.

Badges
------

.. image:: https://badge.fury.io/py/PyAwaish.svg
    :target: https://pypi.org/project/PyAwaish/

.. image:: https://img.shields.io/badge/License-MIT-yellow.svg
    :target: https://opensource.org/licenses/MIT

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 CRUD_App

2. Install the required dependencies:

   .. code-block:: bash

       pip install -r requirements.txt

3. Install the package:

   .. code-block:: bash

       pip install PyAwaish

4. 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


Usage
-----

**Running the Application**

To start the Mysql Web Application server, instantiate the ``MysqlApplication`` class and call its ``execute`` method. For example:

.. code-block:: python

    from PyAwaish.MysqlApplication import MysqlApplication

    if __name__ == "__main__":
        # Initialize MysqlApplication with a secret key
        # Options:
        # 1. Pass the full path of the .env file: MysqlApplication(secret_key=r"full_path_to_env")
        # 2. Pass only the file name if it's in the working directory: MysqlApplication(secret_key=".env")
        # 3. Leave it empty: MysqlApplication()
        # 4. Use a custom string as the secret key:
        app = MysqlApplication(secret_key="your_secret_key")

        # Execute the application
        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.

Function Signature:
-------------------

The ``execute()`` function is used to start the Flask server with customizable parameters.

.. code-block:: python

    def execute(self, debug_mode: bool = False, port_number: int = 5001, host_address: str = "0.0.0.0") -> None:

Parameters:
-----------

- ``debug_mode`` (bool, optional): Enables or disables Flask's debug mode. Default is ``False``.
- ``port_number`` (int, optional): The port number on which the application runs. Default is ``5001``.
- ``host_address`` (str, optional): The host address to bind the server. Default is ``"0.0.0.0"`` (accessible on all network interfaces).

Example Usage:
--------------

.. code-block:: python

    app = MysqlApplication()
    app.execute(debug_mode=True, port_number=8080, host_address="127.0.0.1")

This will run the application in debug mode on localhost (``127.0.0.1``) at port ``8080``.

Initializing MysqlApplication with a Secret Key
-----------------------------------------------

The ``MysqlApplication`` class from ``PyAwaish.MysqlApplication`` requires a secret key for initialization.
This secret key is used for configuration, authentication, or security purposes within the application.
You can provide the secret key in different ways:

1. **Using a `.env` file (Full Path)**

   .. code-block:: python

      app = MysqlApplication(secret_key=r"C:\path\to\.env")

   - Provide the full path to a ``.env`` file that contains necessary environment variables.

2. **Using a `.env` file (Relative Path)**

   .. code-block:: python

      app = MysqlApplication(secret_key=".env")

   - If the ``.env`` file is located in the working directory, you can pass just the filename.

3. **Without a Secret Key**

   .. code-block:: python

      app = MysqlApplication()

   - If no secret key is provided, the application may use default settings.

4. **Using a Custom Secret Key String**

   .. code-block:: python

      app = MysqlApplication(secret_key="your_secret_key")

   - You can directly pass a custom string as the secret key.



Setting Up Secret Key with .env File
------------------------------------

**To securely store and use a secret key in your app, follow these steps:**

**1. Create a `.env` file in the root directory of your project.**

**2. Inside the `.env` file, add the following line:**

.. code-block:: bash

   SECRET_KEY = "YOUR_SECRET_KEY"


Executing the Application
-------------------------

After initialization, you can execute the application using:

.. code-block:: python

   app.execute()

**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 on ``Configure Database``.
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.
- ``python-dotenv``: It loads environment variables from a .env file into os.environ.

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.

Contact
-------

For questions or feedback, contact:

- Email: abuawaish7@gmail.com
- GitHub: https://github.com/abuawaish



[Version 1.6.3] - 2025-02-20

Added:
------

- Introduced a new `static/` folder inside `PyAwaish/` to store static assets.

- Added two PNG images: `mysql.png` and `config.png` inside `static/` for better UI branding.

Changed:
--------

- Updated `setup.py` to include `static/` and its files under `package_data`.

- Updated `MANIFEST.in` to ensure all static assets (images, CSS, JS) are included in the package.

Improved:
---------

- Enhanced the project structure by separating static assets from templates for better maintainability.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/abuawaish",
    "name": "PyAwaish",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "web application flask mysql dynamic templates",
    "author": "Abu Awaish",
    "author_email": "abuawaish7@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6f/6b/be86a8427f711ddd4db059afc42604af5d1878be0eb434accceb0d7a5d59/pyawaish-1.6.3.tar.gz",
    "platform": null,
    "description": "PyAwaish\r\n===========\r\n\r\n**PyAwaish** 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\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\nBadges\r\n------\r\n\r\n.. image:: https://badge.fury.io/py/PyAwaish.svg\r\n    :target: https://pypi.org/project/PyAwaish/\r\n\r\n.. image:: https://img.shields.io/badge/License-MIT-yellow.svg\r\n    :target: https://opensource.org/licenses/MIT\r\n\r\nEndpoints\r\n---------\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\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 CRUD_App\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. Install the package:\r\n\r\n   .. code-block:: bash\r\n\r\n       pip install PyAwaish\r\n\r\n4. 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\n\r\nUsage\r\n-----\r\n\r\n**Running the Application**\r\n\r\nTo start the Mysql Web Application server, instantiate the ``MysqlApplication`` class and call its ``execute`` method. For example:\r\n\r\n.. code-block:: python\r\n\r\n    from PyAwaish.MysqlApplication import MysqlApplication\r\n\r\n    if __name__ == \"__main__\":\r\n        # Initialize MysqlApplication with a secret key\r\n        # Options:\r\n        # 1. Pass the full path of the .env file: MysqlApplication(secret_key=r\"full_path_to_env\")\r\n        # 2. Pass only the file name if it's in the working directory: MysqlApplication(secret_key=\".env\")\r\n        # 3. Leave it empty: MysqlApplication()\r\n        # 4. Use a custom string as the secret key:\r\n        app = MysqlApplication(secret_key=\"your_secret_key\")\r\n\r\n        # Execute the application\r\n        app.execute()\r\n\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\nFunction Signature:\r\n-------------------\r\n\r\nThe ``execute()`` function is used to start the Flask server with customizable parameters.\r\n\r\n.. code-block:: python\r\n\r\n    def execute(self, debug_mode: bool = False, port_number: int = 5001, host_address: str = \"0.0.0.0\") -> None:\r\n\r\nParameters:\r\n-----------\r\n\r\n- ``debug_mode`` (bool, optional): Enables or disables Flask's debug mode. Default is ``False``.\r\n- ``port_number`` (int, optional): The port number on which the application runs. Default is ``5001``.\r\n- ``host_address`` (str, optional): The host address to bind the server. Default is ``\"0.0.0.0\"`` (accessible on all network interfaces).\r\n\r\nExample Usage:\r\n--------------\r\n\r\n.. code-block:: python\r\n\r\n    app = MysqlApplication()\r\n    app.execute(debug_mode=True, port_number=8080, host_address=\"127.0.0.1\")\r\n\r\nThis will run the application in debug mode on localhost (``127.0.0.1``) at port ``8080``.\r\n\r\nInitializing MysqlApplication with a Secret Key\r\n-----------------------------------------------\r\n\r\nThe ``MysqlApplication`` class from ``PyAwaish.MysqlApplication`` requires a secret key for initialization.\r\nThis secret key is used for configuration, authentication, or security purposes within the application.\r\nYou can provide the secret key in different ways:\r\n\r\n1. **Using a `.env` file (Full Path)**\r\n\r\n   .. code-block:: python\r\n\r\n      app = MysqlApplication(secret_key=r\"C:\\path\\to\\.env\")\r\n\r\n   - Provide the full path to a ``.env`` file that contains necessary environment variables.\r\n\r\n2. **Using a `.env` file (Relative Path)**\r\n\r\n   .. code-block:: python\r\n\r\n      app = MysqlApplication(secret_key=\".env\")\r\n\r\n   - If the ``.env`` file is located in the working directory, you can pass just the filename.\r\n\r\n3. **Without a Secret Key**\r\n\r\n   .. code-block:: python\r\n\r\n      app = MysqlApplication()\r\n\r\n   - If no secret key is provided, the application may use default settings.\r\n\r\n4. **Using a Custom Secret Key String**\r\n\r\n   .. code-block:: python\r\n\r\n      app = MysqlApplication(secret_key=\"your_secret_key\")\r\n\r\n   - You can directly pass a custom string as the secret key.\r\n\r\n\r\n\r\nSetting Up Secret Key with .env File\r\n------------------------------------\r\n\r\n**To securely store and use a secret key in your app, follow these steps:**\r\n\r\n**1. Create a `.env` file in the root directory of your project.**\r\n\r\n**2. Inside the `.env` file, add the following line:**\r\n\r\n.. code-block:: bash\r\n\r\n   SECRET_KEY = \"YOUR_SECRET_KEY\"\r\n\r\n\r\nExecuting the Application\r\n-------------------------\r\n\r\nAfter initialization, you can execute the application using:\r\n\r\n.. code-block:: python\r\n\r\n   app.execute()\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 on ``Configure Database``.\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\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\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- ``python-dotenv``: It loads environment variables from a .env file into os.environ.\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\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\n\r\nRefer to ``CHANGELOG.txt`` for the complete version history of the project.\r\n\r\nLicense\r\n-------\r\n\r\nThis project is licensed under the MIT License. See ``LICENSE.txt`` for full details.\r\n\r\nContact\r\n-------\r\n\r\nFor questions or feedback, contact:\r\n\r\n- Email: abuawaish7@gmail.com\r\n- GitHub: https://github.com/abuawaish\r\n\r\n\r\n\r\n[Version 1.6.3] - 2025-02-20\r\n\r\nAdded:\r\n------\r\n\r\n- Introduced a new `static/` folder inside `PyAwaish/` to store static assets.\r\n\r\n- Added two PNG images: `mysql.png` and `config.png` inside `static/` for better UI branding.\r\n\r\nChanged:\r\n--------\r\n\r\n- Updated `setup.py` to include `static/` and its files under `package_data`.\r\n\r\n- Updated `MANIFEST.in` to ensure all static assets (images, CSS, JS) are included in the package.\r\n\r\nImproved:\r\n---------\r\n\r\n- Enhanced the project structure by separating static assets from templates for better maintainability.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python package for building dynamic MySQL-powered web applications with template support",
    "version": "1.6.3",
    "project_urls": {
        "Homepage": "https://github.com/abuawaish"
    },
    "split_keywords": [
        "web",
        "application",
        "flask",
        "mysql",
        "dynamic",
        "templates"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28b18f13c37e5364c5265e0438f6b541fdf9cdb66d1af255e02c8c39989baaf4",
                "md5": "377d4e3e08e50f8499c003ee454a5d0a",
                "sha256": "82c7d532f26a21cf6b9e3bd093a43e006bea3a0d8e572dd04e443cba4439ae64"
            },
            "downloads": -1,
            "filename": "PyAwaish-1.6.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "377d4e3e08e50f8499c003ee454a5d0a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 30225,
            "upload_time": "2025-02-20T06:42:02",
            "upload_time_iso_8601": "2025-02-20T06:42:02.447564Z",
            "url": "https://files.pythonhosted.org/packages/28/b1/8f13c37e5364c5265e0438f6b541fdf9cdb66d1af255e02c8c39989baaf4/PyAwaish-1.6.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6f6bbe86a8427f711ddd4db059afc42604af5d1878be0eb434accceb0d7a5d59",
                "md5": "7ce54dcbdf4ebb4e4a72e0b12f180a8c",
                "sha256": "25c994e556e38729542a0a274f1a5626697d55ee1c41f028904e68cfd57dd92d"
            },
            "downloads": -1,
            "filename": "pyawaish-1.6.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7ce54dcbdf4ebb4e4a72e0b12f180a8c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 34342,
            "upload_time": "2025-02-20T06:42:06",
            "upload_time_iso_8601": "2025-02-20T06:42:06.890596Z",
            "url": "https://files.pythonhosted.org/packages/6f/6b/be86a8427f711ddd4db059afc42604af5d1878be0eb434accceb0d7a5d59/pyawaish-1.6.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-20 06:42:06",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pyawaish"
}
        
Elapsed time: 0.40193s