## 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:
```bash
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:
```python
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:
```python
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...
```
Raw data
{
"_id": null,
"home_page": "https://github.com/STDef200mm/alphaz-next",
"name": "alphaz-next",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Maxime MARTIN",
"author_email": "Maxime MARTIN <maxime.martin02@hotmail.fr>",
"download_url": "https://files.pythonhosted.org/packages/5f/89/7563e7b6e61d5a8e737575a377daefeb1319705dfd6fd46189cf97effc61/alphaz-next-0.7.4.0.tar.gz",
"platform": null,
"description": "## Alphaz-Next\nAlphaz-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.\n\n## Installing\n\nTo install alphaz-next, if you already have Python, you can install with:\n\n```bash\npip install alphaz-next\n```\n\n## Usage\n\nTo use Alphaz-Next in your Python code, import the necessary classes and functions like this:\n\n```\nfrom alphaz-next import DataBase, Logger\nfrom alphaz-next.models.config.config_settings import create_config_settings\n```\n\n## Features\n\n### Logger Setup\n\nThe `Logger` class provides a custom logging functionality with various log levels and output options. It is imported from the `alphaz_next.utils.logger` module.\n\n#### Initialization\n\nThe `Logger` class is initialized with the following parameters:\n\n- `name` (str): The name of the logger.\n- `directory` (str): The directory where the log files will be stored.\n- `level` (int, optional): The log level. Defaults to `logging.INFO`.\n- `stream_output` (bool, optional): If set to `True`, the logs will also be output to the console. Defaults to `True`.\n- `when` (str, optional): Specifies when to rotate the log file. Defaults to `\"midnight\"`.\n- `interval` (int, optional): The interval at which the log file should be rotated. Defaults to `1`.\n- `backup_count` (int, optional): The number of backup log files to keep. Defaults to `10`.\n- `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`.\n- `logging_formatter` (str, optional): The format string for the log messages. Defaults to `DEFAULT_FORMAT`.\n- `date_formatter` (str, optional): The format string for the date in the log messages. Defaults to `DEFAULT_DATE_FORMAT`.\n\n#### Usage\n\nHere's an example of how to use the `Logger` class:\n\n```python\nfrom alphaz_next.utils.logger import Logger\n\nlogger = Logger(\n name=\"my_logger\",\n directory=\"/path/to/log/files\",\n level=logging.INFO,\n stream_output=True,\n when=\"midnight\",\n interval=1,\n backup_count=10,\n file_name=None,\n logging_formatter=DEFAULT_FORMAT,\n date_formatter=DEFAULT_DATE_FORMAT\n)\n\nlogger.info(\"This is an info log message.\")\n```\n\n## Database Connection Setup\nThe Database class represents a database connection and provides methods for various database operations.\n\n### Initialization\nThe Database class is initialized with the following parameters:\n\n- databases_config (_DataBaseConfigTypedDict): A dictionary containing the configuration for the databases.\n- logger (Logger): The logger object to be used for logging.\n- base (DeclarativeMeta): The base class for the declarative models.\n- metadata_views (List[MetaData] | None, optional): A list of metadata views. Defaults to None.\n\n### Usage\n\nHere's an example of how to use the `DataBase` class:\n\n```python\nfrom alphaz_next import DataBase, Logger\n\n# Initialize the logger\nlogger = Logger(\n name='sqlalchemy.engine', \n file_name=\"database\", \n stream_output=False, \n level=logging.DEBUG\n)\n\n# Create the database configuration\ndatabases_config = {\n \"mydb1\": {\n \"host\": \"srv-mydb1-db-dev.example.com\",\n \"password\": \"MyDB1Dev_123\",\n \"username\": \"mydb1adm\",\n \"port\": 1234,\n \"driver\": \"oracledb\",\n \"service_name\": \"mydb1\",\n \"ini\": false\n },\n \"mydb2\": {\n \"path\": \"{{project}}/mydb2.sqlite\",\n \"driver\": \"sqlite\",\n \"ini\": true,\n \"init_database_dir_json\": \"{{project}}/tests/mydb2/ini\",\n \"connect_args\": {\n \"check_same_thread\": false\n }\n }\n}\n\n# Initialize the database connection\ndatabase = DataBase(\n databases_config=databases_config, \n logger=logger, \n base=Base\n)\n\n# Use the database connection\nwith database.session_factory() as session:\n # Perform database operations...\n\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A project to make a lib to start FastAPI quickly",
"version": "0.7.4.0",
"project_urls": {
"Download": "https://github.com/STDef200mm/alphaz-next/archive/refs/tags/0.7.4.0.tar.gz",
"Homepage": "https://github.com/STDef200mm/alphaz-next"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "08020380cef586907698530201f862713214a00a0aa2292825bf3a9d246ebb15",
"md5": "582a3ef123d3ffd607e718cd193f8762",
"sha256": "1ec348e17479d10a81b710519f01b0a0bfcd783de66cf9c62532aeda11dd4426"
},
"downloads": -1,
"filename": "alphaz_next-0.7.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "582a3ef123d3ffd607e718cd193f8762",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 48501,
"upload_time": "2024-07-16T09:48:31",
"upload_time_iso_8601": "2024-07-16T09:48:31.944777Z",
"url": "https://files.pythonhosted.org/packages/08/02/0380cef586907698530201f862713214a00a0aa2292825bf3a9d246ebb15/alphaz_next-0.7.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5f897563e7b6e61d5a8e737575a377daefeb1319705dfd6fd46189cf97effc61",
"md5": "32db08a3d405b0c4823e52e7bd237fcc",
"sha256": "4eb7a723652585a6a9cac0d09ed77600ac88263fd5bda5a58b2f519948600ea3"
},
"downloads": -1,
"filename": "alphaz-next-0.7.4.0.tar.gz",
"has_sig": false,
"md5_digest": "32db08a3d405b0c4823e52e7bd237fcc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 32908,
"upload_time": "2024-07-16T09:48:34",
"upload_time_iso_8601": "2024-07-16T09:48:34.557752Z",
"url": "https://files.pythonhosted.org/packages/5f/89/7563e7b6e61d5a8e737575a377daefeb1319705dfd6fd46189cf97effc61/alphaz-next-0.7.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-16 09:48:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "STDef200mm",
"github_project": "alphaz-next",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "httpx",
"specs": []
},
{
"name": "python-jose",
"specs": []
},
{
"name": "python-multipart",
"specs": []
},
{
"name": "fastapi",
"specs": [
[
">=",
"0.108.0"
]
]
},
{
"name": "pydantic_settings",
"specs": []
},
{
"name": "pydantic",
"specs": [
[
">=",
"2.5"
],
[
"<",
"3.0.0"
]
]
},
{
"name": "sqlalchemy_utils",
"specs": []
},
{
"name": "email-validator",
"specs": []
},
{
"name": "deepdiff",
"specs": []
},
{
"name": "unidecode",
"specs": []
},
{
"name": "pysql-repo",
"specs": [
[
"==",
"0.7.4.0"
]
]
},
{
"name": "loguru",
"specs": []
},
{
"name": "opentelemetry-api",
"specs": []
},
{
"name": "opentelemetry-exporter-otlp-proto-http",
"specs": []
},
{
"name": "opentelemetry-instrumentation-fastapi",
"specs": []
},
{
"name": "opentelemetry-instrumentation-sqlalchemy",
"specs": []
},
{
"name": "opentelemetry-instrumentation-system-metrics",
"specs": []
},
{
"name": "opentelemetry-instrumentation-logging",
"specs": []
},
{
"name": "opentelemetry-sdk",
"specs": []
}
],
"lcname": "alphaz-next"
}