Skip to main content

Alphaz-Next

Alphaz-Next is a Python library designed to simplify the setup of REST APIs using FastAPI & Pydantic. It provides a useful toolkit for setting up Logger, Config, and more.

Installing

To install alphaz-next, if you already have Python, you can install with:

pip install alphaz-next

Usage

To use Alphaz-Next in your Python code, import the necessary classes and functions like this:

from alphaz-next import DataBase, Logger
from alphaz-next.models.config.config_settings import create_config_settings

Features

Logger Setup

The Logger class provides a custom logging functionality with various log levels and output options. It is imported from the alphaz_next.utils.logger module.

Initialization

The Logger class is initialized with the following parameters:

  • name (str): The name of the logger.
  • directory (str): The directory where the log files will be stored.
  • level (int, optional): The log level. Defaults to logging.INFO.
  • stream_output (bool, optional): If set to True, the logs will also be output to the console. Defaults to True.
  • when (str, optional): Specifies when to rotate the log file. Defaults to "midnight".
  • interval (int, optional): The interval at which the log file should be rotated. Defaults to 1.
  • backup_count (int, optional): The number of backup log files to keep. Defaults to 10.
  • file_name (str, optional): The name of the log file. If not provided, the log file will be named after the logger. Defaults to None.
  • logging_formatter (str, optional): The format string for the log messages. Defaults to DEFAULT_FORMAT.
  • date_formatter (str, optional): The format string for the date in the log messages. Defaults to DEFAULT_DATE_FORMAT.

Usage

Here's an example of how to use the Logger class:

from alphaz_next.utils.logger import Logger

logger = Logger(
    name="my_logger",
    directory="/path/to/log/files",
    level=logging.INFO,
    stream_output=True,
    when="midnight",
    interval=1,
    backup_count=10,
    file_name=None,
    logging_formatter=DEFAULT_FORMAT,
    date_formatter=DEFAULT_DATE_FORMAT
)

logger.info("This is an info log message.")

Database Connection Setup

The Database class represents a database connection and provides methods for various database operations.

Initialization

The Database class is initialized with the following parameters:

  • databases_config (_DataBaseConfigTypedDict): A dictionary containing the configuration for the databases.
  • logger (Logger): The logger object to be used for logging.
  • base (DeclarativeMeta): The base class for the declarative models.
  • metadata_views (List[MetaData] | None, optional): A list of metadata views. Defaults to None.

Usage

Here's an example of how to use the DataBase class:

from alphaz_next import DataBase, Logger

# Initialize the logger
logger = Logger(
    name='sqlalchemy.engine', 
    file_name="database", 
    stream_output=False, 
    level=logging.DEBUG
)

# Create the database configuration
databases_config = {
    "mydb1": {
        "host": "srv-mydb1-db-dev.example.com",
        "password": "MyDB1Dev_123",
        "username": "mydb1adm",
        "port": 1234,
        "driver": "oracledb",
        "service_name": "mydb1",
        "ini": false
    },
    "mydb2": {
        "path": "{{project}}/mydb2.sqlite",
        "driver": "sqlite",
        "ini": true,
        "init_database_dir_json": "{{project}}/tests/mydb2/ini",
        "connect_args": {
            "check_same_thread": false
        }
    }
}

# Initialize the database connection
database = DataBase(
    databases_config=databases_config, 
    logger=logger, 
    base=Base
)

# Use the database connection
with database.session_factory() as session:
    # Perform database operations...

Metadata

Release files for alphaz-next 0.7.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alphaz-next 0.7.4.0
File Size Uploaded Provenance Actions
alphaz-next-0.7.4.0.tar.gz 32.9 kB Without provenance Details for alphaz-next-0.7.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for alphaz-next 0.7.4.0
File Interpreter ABI Platform Actions
alphaz_next-0.7.4.0-py3-none-any.whl Python 3 none any Details for alphaz_next-0.7.4.0-py3-none-any.whl

Total release size: 81.4 kB

Release files / alphaz-next-0.7.4.0.tar.gz

Download URL alphaz-next-0.7.4.0.tar.gz
Size 32.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4eb7a723652585a6a9cac0d09ed77600ac88263fd5bda5a58b2f519948600ea3
BLAKE2b-256 checksum
How to use checksums
5f897563e7b6e61d5a8e737575a377daefeb1319705dfd6fd46189cf97effc61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / alphaz_next-0.7.4.0-py3-none-any.whl

Download URL alphaz_next-0.7.4.0-py3-none-any.whl
Size 48.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ec348e17479d10a81b710519f01b0a0bfcd783de66cf9c62532aeda11dd4426
BLAKE2b-256 checksum
How to use checksums
08020380cef586907698530201f862713214a00a0aa2292825bf3a9d246ebb15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Security for alphaz-next 0.7.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.7.4.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page