diff --git a/dist/pysqltools-0.2.2-py3-none-any.whl b/dist/pysqltools-0.2.2-py3-none-any.whl new file mode 100644 index 0000000..4edee35 Binary files /dev/null and b/dist/pysqltools-0.2.2-py3-none-any.whl differ diff --git a/dist/pysqltools-0.2.2.tar.gz b/dist/pysqltools-0.2.2.tar.gz new file mode 100644 index 0000000..5d76892 Binary files /dev/null and b/dist/pysqltools-0.2.2.tar.gz differ diff --git a/pyproject.toml b/pyproject.toml index e48dbdb..9933dc8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pysqltools" -version = "0.2.1" +version = "0.2.2" description = "PySQLTools" authors = ["Pablo Minué"] license = "None" diff --git a/pysqltools/src/connection/connection.py b/pysqltools/src/connection/connection.py index c571ce3..def3384 100644 --- a/pysqltools/src/connection/connection.py +++ b/pysqltools/src/connection/connection.py @@ -6,7 +6,8 @@ import mysql.connector import pymssql import pymysql -import pyodbc + +# import pyodbc import sqlalchemy import trino @@ -27,7 +28,7 @@ def __init__( trino.dbapi.Connection, pymssql.Connection, sqlite3.Connection, - pyodbc.Connection, + # pyodbc.Connection, mysql.connector.connection.MySQLConnection, mysql.connector.connection_cext.CMySQLConnection, ibm_db.IBM_DBConnection, diff --git a/pysqltools/src/log/log.py b/pysqltools/src/log/log.py index 55b5721..0b252ea 100644 --- a/pysqltools/src/log/log.py +++ b/pysqltools/src/log/log.py @@ -1,11 +1,14 @@ """Logger""" import logging +from typing import Any, Callable import pandas as pd +import rich from rich.console import Console from rich.logging import RichHandler from rich.markdown import Markdown +from rich.progress import Progress from rich.table import Table COLORS = [ @@ -70,3 +73,26 @@ def add_title(self, title: str): md_ = f" # **{title}** " md = Markdown(md_) self.console.print(md) + + +def progress_function( + task_name: str = "Task in progress...", color: str = "green", total: int = 100 +): + """ + Decorator to use a rich progress bar + """ + + def decorator(fun: Callable[..., Any]): + """Decorator""" + + def inner(*args, **kwargs): + """Wrapped""" + with Progress() as progress: + task = progress.add_task("f[{color}] {task_name}...", total=total) + result = fun(progress, task, *args, **kwargs) + progress.update(task, advance=total) + return result + + return inner + + return decorator