Reusable Python utilities.
Project description
Zut
Reusable Python utilities.
Installation
Zut package is published on PyPI. Install with default, minimal dependencies:
pip install zut[default]
Other possible dependency specifications:
pip install zut
: no dependency at all is installedpip install zut[excel]
: dependencies to manage Excel files (including openpyxl)pip install zut[smb]
: dependencies to access files on Samba shares from Linux, or on Windows with non-standard security context (including smbprotocol) - Not required to access Samba shares from Windows using default credentialspip install zut[sqlite]
: dependencies to connect with a SQLite database (sqlparse)pip install zut[postgresql]
(or[pg]
) : dependencies to connect with a PostgreSQL database (psycopg and sqlparse)pip install zut[mariadb]
(or[mysql]
) : dependencies to connect with a MariaDB or MySQL database (mysqlclient and sqlparse)pip install zut[sqlserver]
: dependencies to connect with a Microsoft SQL Server database (including pyodbc and sqlparse)
Usage examples
See also full documentation (including API reference).
Configure logging
from zut import configure_logging
configure_logging()
Flexible output
Write tabular data to a flexible, easily configurable output: CSV or Excel file, or tabulated stdout/stderr.
The output file may be on the local file system or on a Windows/Samba share (including when the library is used on Linux).
Export tabular data to stdout or to a file:
import sys
from zut import tabular_dumper
with tabular_dumper(filename or sys.stdout, headers=["Id", "Word"]) as t:
t.append([1, "Hello"])
t.append([2, "World"])
Tabular data can also be exported using dictionnaries (in this case, headers will be detected automatically by the library):
import sys
from zut import tabular_dumper
with tabular_dumper(filename or sys.stdout) as t:
t.append({'id': 1, 'name': "Hello"})
t.append({'id': 2, 'col3': True})
If filename
has extension with .xlsx
, output will be in Excel 2010 format.
Otherwise it will be in CSV format.
If filename
starts with \\
, output will be done on the corresponding Windows/Samba share.
To indicate Samba credentials, call configure_smb_credentials
before using function tabular_dumper
.
Example:
from zut import tabular_dumper, configure_smb_credentials
configure_smb_credentials(user=..., password=...)
with tabular_dumper(r"\\server\share\path\to\file") as o:
...
Legal
This project is licensed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file zut-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: zut-1.0.0-py3-none-any.whl
- Upload date:
- Size: 72.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4eb76a0f77436bc55595078db1afbb706490a063808600e695e733eae387dea |
|
MD5 | 48126f3f221ac66894ad4cdaea0ce417 |
|
BLAKE2b-256 | dfed31f3df633389283fa3b931f503b60b6a67406b78644c6394d124138c84b5 |