psvutils


Namepsvutils JSON
Version 0.0.7 PyPI version JSON
download
home_page
SummaryBasic util library for progress bar and cron trigger and mssql db check related operation
upload_time2023-11-01 13:05:25
maintainer
docs_urlNone
authorPritam Sarkar 1995
requires_python
license
keywords python psvutils quartz quartzcron quartz cron cron cron triggers quartzcron triggers mssql_db_check
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# psvutils



Under construction! Not ready for use yet! Currently experimenting and planning!



Developed by Pritam Sarkar 1995 from [pritamSarkar123](https://github.com/pritamSarkar123) (c) 2023



## Examples of How To Use (Alpha Version + Buggy)



Creating A Progressbar



```python

from psvutils import Progressbar



pb = ProgressBar(total=200)



for _ in range(200):

    """main code block"""

    pb.update()



```



```

(venv) C:\***\***>python main.py

████████████████████████████████████████████████████████████████████████████████████████████████████|100.00%

```



```python

"""

    Args:

        total (int): The total number of items in the task.

        progress (int, optional): The current progress value (default is 0).

        counter (int, optional): The amount by which the progress increases in each update (default is 1).

        color (str, optional): The color to use for the progress bar (default is colorama.Fore.YELLOW).

        end_color (str, optional): The color to use for the progress bar when it reaches 100% (default is colorama.Fore.GREEN).

    Returns:

        A Progressbar instance

"""

```



Creating a quartz cron based trigger



```python

from psvutils import Trigger

tr = Trigger("0 * 0 ? * * *", start_date=datetime.datetime.now())



print(Trigger.check_valid_cron_or_not("0 * 0 ? * * *"))



for _ in range(20):

    """next 20 triggers"""

    print(tr.get_next())

```



```

(venv) C:\***\***>python main.py

True

2023-10-19 13:49:00

2023-10-19 13:50:00

2023-10-19 13:51:00

2023-10-19 13:52:00

2023-10-19 13:53:00

2023-10-19 13:54:00

2023-10-19 13:55:00

2023-10-19 13:56:00

2023-10-19 13:57:00

2023-10-19 13:58:00

2023-10-19 13:59:00

2027-10-14 13:49:00

2027-10-14 13:50:00

2027-10-14 13:51:00

2027-10-14 13:52:00

2027-10-14 13:53:00

2027-10-14 13:54:00

2027-10-14 13:55:00

2027-10-14 13:56:00

2027-10-14 13:57:00

```



```python

"""

    Args:

        quartz_expression (str): A Quartz Cron expression.

        infinite (bool): Whether the trigger should run infinitely.

        start_date (datetime.datetime, optional): The start date for the trigger.

        end_date (datetime.datetime, optional): The end date for a finite run.

        default_week_delta (int, optional): The default number of weeks to run.



    Returns:

        A Trigger instance

"""

```



```python

from psvutils import check_mssql_db_connection

databaseConfigs = {'username': 'xxxx', 'password':'xxxx', 'windows_integrated_auth':False, 'domain': '', 'server_name': 'DESKTOP-G2UIUMK\SQLEXPESS,1435', 'database':'xxx','driver_name':'SQL Server' }

query = "SELECT * FROM sys.tables"





print(check_mssql_db_connection(databaseConfigs, query)) # incorrect databaseConfigs or query

print(check_mssql_db_connection(databaseConfigs, query)) # correct databaseConfigs or query

print(check_mssql_db_connection(databaseConfigs)) # incorrect databaseConfigs or query

print(check_mssql_db_connection(databaseConfigs)) # correct databaseConfigs or query

```



```

C:\***\***>python main.py

(False, 'Database Connection Failed!')

(True, 'Connection Established And Found Tables!')

(False, 'Database Connection Failed!')

(True, 'Connection Established And Found Tables!')

(False, 'Database Connection Failed!')

```



```python

"""

    Checks the database connection and executes a SELECT query.



    Parameters:

    - databaseConfigs (Dict[str, str]): A dictionary containing the configuration settings for the database connection. It should include keys such as 'host', 'port', 'user', 'password', 'database', and any other required parameters, all of type str.

    - query (str): The SQL query to be executed, which is expected to be a SELECT query.



    Returns:

    - Tuple (bool, str):

        - A boolean value indicating the success of the operation.

            - True if the connection is established and the query returns results.

            - False if there are any failures during the operation.

        - A message describing the outcome of the operation.



    Note:

    - This function updates the 'query' key in the 'databaseConfigs' dictionary with the provided query.

    - It attempts to establish a database connection and execute the given SELECT query.

    - If the query is a SELECT query and the connection is successful, it checks if any tables are returned.

    - If tables are found, it returns True and a success message. Otherwise, it returns False and a relevant error message.

    - If there are any exceptions during the operation, it returns False and an error message.



    Example Usage:

    database_config = {

        'host': 'localhost',

        'port': '3306',

        'user': 'username',

        'password': 'password',

        'database': 'my_database',

    }

    query = "SELECT * FROM my_table"

    success, message = check(database_config, query)

    if success:

        print(message)  # Connection Established And Found Tables!

    else:

        print(message)  # Database Connection Failed!

    """

```


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "psvutils",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,psvutils,quartz,quartzcron,quartz cron,cron,cron triggers,quartzcron triggers,mssql_db_check",
    "author": "Pritam Sarkar 1995",
    "author_email": "<pritamsarkar84028220@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/89/1f/e6c50187da673dbf375e03f1dd58896f6d80f6516c8d78e79cdfc8e67d9a/psvutils-0.0.7.tar.gz",
    "platform": null,
    "description": "\r\n# psvutils\r\n\r\n\r\n\r\nUnder construction! Not ready for use yet! Currently experimenting and planning!\r\n\r\n\r\n\r\nDeveloped by Pritam Sarkar 1995 from [pritamSarkar123](https://github.com/pritamSarkar123) (c) 2023\r\n\r\n\r\n\r\n## Examples of How To Use (Alpha Version + Buggy)\r\n\r\n\r\n\r\nCreating A Progressbar\r\n\r\n\r\n\r\n```python\r\n\r\nfrom psvutils import Progressbar\r\n\r\n\r\n\r\npb = ProgressBar(total=200)\r\n\r\n\r\n\r\nfor _ in range(200):\r\n\r\n    \"\"\"main code block\"\"\"\r\n\r\n    pb.update()\r\n\r\n\r\n\r\n```\r\n\r\n\r\n\r\n```\r\n\r\n(venv) C:\\***\\***>python main.py\r\n\r\n\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588|100.00%\r\n\r\n```\r\n\r\n\r\n\r\n```python\r\n\r\n\"\"\"\r\n\r\n    Args:\r\n\r\n        total (int): The total number of items in the task.\r\n\r\n        progress (int, optional): The current progress value (default is 0).\r\n\r\n        counter (int, optional): The amount by which the progress increases in each update (default is 1).\r\n\r\n        color (str, optional): The color to use for the progress bar (default is colorama.Fore.YELLOW).\r\n\r\n        end_color (str, optional): The color to use for the progress bar when it reaches 100% (default is colorama.Fore.GREEN).\r\n\r\n    Returns:\r\n\r\n        A Progressbar instance\r\n\r\n\"\"\"\r\n\r\n```\r\n\r\n\r\n\r\nCreating a quartz cron based trigger\r\n\r\n\r\n\r\n```python\r\n\r\nfrom psvutils import Trigger\r\n\r\ntr = Trigger(\"0 * 0 ? * * *\", start_date=datetime.datetime.now())\r\n\r\n\r\n\r\nprint(Trigger.check_valid_cron_or_not(\"0 * 0 ? * * *\"))\r\n\r\n\r\n\r\nfor _ in range(20):\r\n\r\n    \"\"\"next 20 triggers\"\"\"\r\n\r\n    print(tr.get_next())\r\n\r\n```\r\n\r\n\r\n\r\n```\r\n\r\n(venv) C:\\***\\***>python main.py\r\n\r\nTrue\r\n\r\n2023-10-19 13:49:00\r\n\r\n2023-10-19 13:50:00\r\n\r\n2023-10-19 13:51:00\r\n\r\n2023-10-19 13:52:00\r\n\r\n2023-10-19 13:53:00\r\n\r\n2023-10-19 13:54:00\r\n\r\n2023-10-19 13:55:00\r\n\r\n2023-10-19 13:56:00\r\n\r\n2023-10-19 13:57:00\r\n\r\n2023-10-19 13:58:00\r\n\r\n2023-10-19 13:59:00\r\n\r\n2027-10-14 13:49:00\r\n\r\n2027-10-14 13:50:00\r\n\r\n2027-10-14 13:51:00\r\n\r\n2027-10-14 13:52:00\r\n\r\n2027-10-14 13:53:00\r\n\r\n2027-10-14 13:54:00\r\n\r\n2027-10-14 13:55:00\r\n\r\n2027-10-14 13:56:00\r\n\r\n2027-10-14 13:57:00\r\n\r\n```\r\n\r\n\r\n\r\n```python\r\n\r\n\"\"\"\r\n\r\n    Args:\r\n\r\n        quartz_expression (str): A Quartz Cron expression.\r\n\r\n        infinite (bool): Whether the trigger should run infinitely.\r\n\r\n        start_date (datetime.datetime, optional): The start date for the trigger.\r\n\r\n        end_date (datetime.datetime, optional): The end date for a finite run.\r\n\r\n        default_week_delta (int, optional): The default number of weeks to run.\r\n\r\n\r\n\r\n    Returns:\r\n\r\n        A Trigger instance\r\n\r\n\"\"\"\r\n\r\n```\r\n\r\n\r\n\r\n```python\r\n\r\nfrom psvutils import check_mssql_db_connection\r\n\r\ndatabaseConfigs = {'username': 'xxxx', 'password':'xxxx', 'windows_integrated_auth':False, 'domain': '', 'server_name': 'DESKTOP-G2UIUMK\\SQLEXPESS,1435', 'database':'xxx','driver_name':'SQL Server' }\r\n\r\nquery = \"SELECT * FROM sys.tables\"\r\n\r\n\r\n\r\n\r\n\r\nprint(check_mssql_db_connection(databaseConfigs, query)) # incorrect databaseConfigs or query\r\n\r\nprint(check_mssql_db_connection(databaseConfigs, query)) # correct databaseConfigs or query\r\n\r\nprint(check_mssql_db_connection(databaseConfigs)) # incorrect databaseConfigs or query\r\n\r\nprint(check_mssql_db_connection(databaseConfigs)) # correct databaseConfigs or query\r\n\r\n```\r\n\r\n\r\n\r\n```\r\n\r\nC:\\***\\***>python main.py\r\n\r\n(False, 'Database Connection Failed!')\r\n\r\n(True, 'Connection Established And Found Tables!')\r\n\r\n(False, 'Database Connection Failed!')\r\n\r\n(True, 'Connection Established And Found Tables!')\r\n\r\n(False, 'Database Connection Failed!')\r\n\r\n```\r\n\r\n\r\n\r\n```python\r\n\r\n\"\"\"\r\n\r\n    Checks the database connection and executes a SELECT query.\r\n\r\n\r\n\r\n    Parameters:\r\n\r\n    - databaseConfigs (Dict[str, str]): A dictionary containing the configuration settings for the database connection. It should include keys such as 'host', 'port', 'user', 'password', 'database', and any other required parameters, all of type str.\r\n\r\n    - query (str): The SQL query to be executed, which is expected to be a SELECT query.\r\n\r\n\r\n\r\n    Returns:\r\n\r\n    - Tuple (bool, str):\r\n\r\n        - A boolean value indicating the success of the operation.\r\n\r\n            - True if the connection is established and the query returns results.\r\n\r\n            - False if there are any failures during the operation.\r\n\r\n        - A message describing the outcome of the operation.\r\n\r\n\r\n\r\n    Note:\r\n\r\n    - This function updates the 'query' key in the 'databaseConfigs' dictionary with the provided query.\r\n\r\n    - It attempts to establish a database connection and execute the given SELECT query.\r\n\r\n    - If the query is a SELECT query and the connection is successful, it checks if any tables are returned.\r\n\r\n    - If tables are found, it returns True and a success message. Otherwise, it returns False and a relevant error message.\r\n\r\n    - If there are any exceptions during the operation, it returns False and an error message.\r\n\r\n\r\n\r\n    Example Usage:\r\n\r\n    database_config = {\r\n\r\n        'host': 'localhost',\r\n\r\n        'port': '3306',\r\n\r\n        'user': 'username',\r\n\r\n        'password': 'password',\r\n\r\n        'database': 'my_database',\r\n\r\n    }\r\n\r\n    query = \"SELECT * FROM my_table\"\r\n\r\n    success, message = check(database_config, query)\r\n\r\n    if success:\r\n\r\n        print(message)  # Connection Established And Found Tables!\r\n\r\n    else:\r\n\r\n        print(message)  # Database Connection Failed!\r\n\r\n    \"\"\"\r\n\r\n```\r\n\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Basic util library for progress bar and cron trigger and mssql db check related operation",
    "version": "0.0.7",
    "project_urls": null,
    "split_keywords": [
        "python",
        "psvutils",
        "quartz",
        "quartzcron",
        "quartz cron",
        "cron",
        "cron triggers",
        "quartzcron triggers",
        "mssql_db_check"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b84554fae6b01aa61c85499e65c2578e92e9d9e7e3ed569e03ad3a2eb5964d2e",
                "md5": "8a23cafdb7987dcdd392174e5df950e7",
                "sha256": "25fec1df73d5ab2479b17d1c083d071c318cfed741a732f1a7732387b9b7b483"
            },
            "downloads": -1,
            "filename": "psvutils-0.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8a23cafdb7987dcdd392174e5df950e7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8170,
            "upload_time": "2023-11-01T13:05:22",
            "upload_time_iso_8601": "2023-11-01T13:05:22.830992Z",
            "url": "https://files.pythonhosted.org/packages/b8/45/54fae6b01aa61c85499e65c2578e92e9d9e7e3ed569e03ad3a2eb5964d2e/psvutils-0.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "891fe6c50187da673dbf375e03f1dd58896f6d80f6516c8d78e79cdfc8e67d9a",
                "md5": "1aba42ba2d72e08bcb9ceb5f20c05af4",
                "sha256": "3d2c63f750f5e8f3ca0ecd6df0f40d149c94fc7ab70ef4c9b93965647d815481"
            },
            "downloads": -1,
            "filename": "psvutils-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "1aba42ba2d72e08bcb9ceb5f20c05af4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7833,
            "upload_time": "2023-11-01T13:05:25",
            "upload_time_iso_8601": "2023-11-01T13:05:25.221111Z",
            "url": "https://files.pythonhosted.org/packages/89/1f/e6c50187da673dbf375e03f1dd58896f6d80f6516c8d78e79cdfc8e67d9a/psvutils-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-01 13:05:25",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "psvutils"
}
        
Elapsed time: 0.17842s