Skip to content

notvillers/villog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Villog is a simple python utility tool for your everyday projects.

Modules

  • Logger
  • Excel generator
  • Excel reader
  • MSSQL handler
  • PDF generator

Logger

from villog import Logger

l: Logger = Logger(file_path = "example.log",
                   encoding = "utf-8-sig",
                   time_format = "%Y.%m.%d %H:%M:%S",
                   separator = "\t",
                   silent = False,
                   enable_remove = False,
                   strip_content = True)

l.log(content = "example_content")

Write Excel

from villog.writexcel import WorkSheet, WorkBook

sheet_1: WorkSheet = WorkSheet(name = "Sheet1",
                               header = ["header_1", "header_2", "header_3"],
                               data = [["data_1", "data_2", "data_3"],
                                       ["data_4", "data_5", "data_6"]])

sheet_2: WorkSheet = WorkSheet(name = "Sheet2",
                               header = ["header_1", "header_2", "header_3"],
                               data = [["data_1", "data_2", "data_3"],
                                       ["data_4", "data_5", "data_6"]])

book: WorkBook = WorkBook(name = "Book1",
                          sheets = [sheet_1, sheet_2])

book.xlsx_create(file_path = "example.xlsx")

Read Excel

from villog import ReadExcel

excel: ReadExcel = ReadExcel(path = "example.xlsx")

excel.read()

for sheet_name in read_excel.get_sheet_names():
    for row in excel.get_sheet_content_to_list(sheet_name):
        for elem in row:
            print(elem, end = "\t")

VillSQL

from villog.mssql import VillSQL, Table

login_dict: dict[str, str] = {"server": "server_name",
                              "database": "database_name",
                              "username": "username",
                              "password": "password"}

sql_client: VillSQL = VillSQL(login_data = login_dict)

egt: Table = sql_client.get_table("EXAMPLE_T",
                                  raw_filter="col_1 = "example",
                                  order_by = ["col_1","ASC",
                                              "col_3","DESC"],
                                              # kwargs:
                                              COL_4 = 1)

egt.set_filter(column_names = ["col_1, "col_2"])

print("COLUMNS:")
for column in egt.columns():
    print(column, end = "\t")
print("\nROWS:)
for row in egt.rows:
    for elem in row:
        print(elem, end = "\t")
"""
Output:
    COLUMNS:
    col_1   col_2
    ROWS:
    val_1_1 val_1_2
    val_2_1 val_2_2
    val_3_1 val_3_2
"""

villsql_client.close()

PDF generator

from villog import generate_pdf

generate_pdf(html_string = "html_string",
             output_path = "example.pdf",
             css_string = "css_string")

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages