envrx


Nameenvrx JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/Starkgang/envrx
SummaryA package to manage environment variables with database and custom env file support.
upload_time2023-12-23 12:06:46
maintainer
docs_urlNone
authorWarnerStark
requires_python
license
keywords envrx env environment variables database mongodb sql redis
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ENVRX

`ENVRX` is a Python class designed to manage environment variables seamlessly, providing support for various databases such as MongoDB, SQL, and Redis.
It also supports env files (let it be .json, .env or even .yaml)

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [Class Initialization](#class-initialization)
- [Loading Environment](#loading-environment)
- [Database Operations](#database-operations)
- [Examples](#examples)
- [License](#license)

## Installation

```bash
pip install envrx
```

- If you are using mongodb for database:
```pip install pymongo```
- or If using postgreSQL
```pip install psycopg2```
- or If using Redis
```pip install redis```
- Sqlite uses ```sqlite3```


## Usage

```python
from envrx import ENVRX
import os

# Initialize ENVRX with optional parameters
env_manager = ENVRX(env_file=".env", database="mongodb://localhost:27017", collection_or_table_name="env_variables")

# or pass a database client client
client = MongoClient(...)
env_manager = ENVRX(env_file=".env", database=client, collection_or_table_name="env_variables")

# Initialize the environment
env_manager.initialize()
# Access loaded env
print(os.getenv("env_from_db_or_file"))
```

## Class Initialization

- `env_file` (Optional): Path to the environment file.
- `database` (Optional): Database URL for MongoDB, SQL, or Redis.
- `collection_or_table_name` (Optional): Name of the collection or table in the database.

```python
# Example initialization
env_manager = ENVRX(env_file=".env", database="mongodb://localhost:27017", collection_or_table_name="env_variables")
# or if you have a database client
client = MongoClient(...)
env_manager = ENVRX(env_file=".env", database=client, collection_or_table_name="env_variables")
```

## Loading Environment

- `initialize()`: Initializes the class and loads environment variables from both the specified file and database.

```python
# Example loading environment
env_manager.initialize()
```

- Please note that, all variables will be auto loaded when running this and can be accessed through ```os.environ.get("foo_bar")```

## Database Operations

- `load_from_database()`: Loads environment variables from the specified database.

- `get_env_from_database(key)`: Gets a specific environment variable from the database.

- `get_all_env_from_database()`: Gets all environment variables from the database.

- `load_env_to_database(key, value)`: Loads a new environment variable to the database.

- `delete_env_from_database(key)`: Deletes an environment variable from the database.

- `update_env_in_database(key, value)`: Updates an environment variable in the database.

```python
# Example database operations
value = env_manager.get_env_from_database("KEY_NAME")
env_manager.load_env_to_database("NEW_KEY", "NEW_VALUE")
env_manager.delete_env_from_database("OLD_KEY")
env_manager.update_env_in_database("EXISTING_KEY", "UPDATED_VALUE")
```

## Examples

Database wise Examples can be found [here](https://github.com/StarkGang/EnvrX/tree/main/examples).


## License

This project is licensed under the [GPL V3.0](https://github.com/StarkGang/EnvrX/blob/main/LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Starkgang/envrx",
    "name": "envrx",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "envrx,env,environment,variables,database,mongodb,sql,redis",
    "author": "WarnerStark",
    "author_email": "starktechfriday@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d3/37/a4abfe793d0d418581ae3cf6aa251bb772aaf24cf16961ac755415b579b4/envrx-0.0.3.tar.gz",
    "platform": null,
    "description": "# ENVRX\n\n`ENVRX` is a Python class designed to manage environment variables seamlessly, providing support for various databases such as MongoDB, SQL, and Redis.\nIt also supports env files (let it be .json, .env or even .yaml)\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Class Initialization](#class-initialization)\n- [Loading Environment](#loading-environment)\n- [Database Operations](#database-operations)\n- [Examples](#examples)\n- [License](#license)\n\n## Installation\n\n```bash\npip install envrx\n```\n\n- If you are using mongodb for database:\n```pip install pymongo```\n- or If using postgreSQL\n```pip install psycopg2```\n- or If using Redis\n```pip install redis```\n- Sqlite uses ```sqlite3```\n\n\n## Usage\n\n```python\nfrom envrx import ENVRX\nimport os\n\n# Initialize ENVRX with optional parameters\nenv_manager = ENVRX(env_file=\".env\", database=\"mongodb://localhost:27017\", collection_or_table_name=\"env_variables\")\n\n# or pass a database client client\nclient = MongoClient(...)\nenv_manager = ENVRX(env_file=\".env\", database=client, collection_or_table_name=\"env_variables\")\n\n# Initialize the environment\nenv_manager.initialize()\n# Access loaded env\nprint(os.getenv(\"env_from_db_or_file\"))\n```\n\n## Class Initialization\n\n- `env_file` (Optional): Path to the environment file.\n- `database` (Optional): Database URL for MongoDB, SQL, or Redis.\n- `collection_or_table_name` (Optional): Name of the collection or table in the database.\n\n```python\n# Example initialization\nenv_manager = ENVRX(env_file=\".env\", database=\"mongodb://localhost:27017\", collection_or_table_name=\"env_variables\")\n# or if you have a database client\nclient = MongoClient(...)\nenv_manager = ENVRX(env_file=\".env\", database=client, collection_or_table_name=\"env_variables\")\n```\n\n## Loading Environment\n\n- `initialize()`: Initializes the class and loads environment variables from both the specified file and database.\n\n```python\n# Example loading environment\nenv_manager.initialize()\n```\n\n- Please note that, all variables will be auto loaded when running this and can be accessed through ```os.environ.get(\"foo_bar\")```\n\n## Database Operations\n\n- `load_from_database()`: Loads environment variables from the specified database.\n\n- `get_env_from_database(key)`: Gets a specific environment variable from the database.\n\n- `get_all_env_from_database()`: Gets all environment variables from the database.\n\n- `load_env_to_database(key, value)`: Loads a new environment variable to the database.\n\n- `delete_env_from_database(key)`: Deletes an environment variable from the database.\n\n- `update_env_in_database(key, value)`: Updates an environment variable in the database.\n\n```python\n# Example database operations\nvalue = env_manager.get_env_from_database(\"KEY_NAME\")\nenv_manager.load_env_to_database(\"NEW_KEY\", \"NEW_VALUE\")\nenv_manager.delete_env_from_database(\"OLD_KEY\")\nenv_manager.update_env_in_database(\"EXISTING_KEY\", \"UPDATED_VALUE\")\n```\n\n## Examples\n\nDatabase wise Examples can be found [here](https://github.com/StarkGang/EnvrX/tree/main/examples).\n\n\n## License\n\nThis project is licensed under the [GPL V3.0](https://github.com/StarkGang/EnvrX/blob/main/LICENSE).\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A package to manage environment variables with database and custom env file support.",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/Starkgang/envrx"
    },
    "split_keywords": [
        "envrx",
        "env",
        "environment",
        "variables",
        "database",
        "mongodb",
        "sql",
        "redis"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f6bc63864cd0a6e4a7dc565908721f7a4733fe0338cc268c6c0e955898732951",
                "md5": "e8f0b38e5669f459d363f9b20a7dffac",
                "sha256": "2ed61635945d0940d31dc0a9dfcd9a6d5f6a05a3c831447f21b360c70cdf7579"
            },
            "downloads": -1,
            "filename": "envrx-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e8f0b38e5669f459d363f9b20a7dffac",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 18842,
            "upload_time": "2023-12-23T12:06:44",
            "upload_time_iso_8601": "2023-12-23T12:06:44.409440Z",
            "url": "https://files.pythonhosted.org/packages/f6/bc/63864cd0a6e4a7dc565908721f7a4733fe0338cc268c6c0e955898732951/envrx-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d337a4abfe793d0d418581ae3cf6aa251bb772aaf24cf16961ac755415b579b4",
                "md5": "ee7d7244f510766431885fd0bf1bb935",
                "sha256": "ed55a1ee1f7c27fe1fd92c58189058a70647ba229558fda6afe75af4988b263f"
            },
            "downloads": -1,
            "filename": "envrx-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "ee7d7244f510766431885fd0bf1bb935",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 18838,
            "upload_time": "2023-12-23T12:06:46",
            "upload_time_iso_8601": "2023-12-23T12:06:46.034631Z",
            "url": "https://files.pythonhosted.org/packages/d3/37/a4abfe793d0d418581ae3cf6aa251bb772aaf24cf16961ac755415b579b4/envrx-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-23 12:06:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Starkgang",
    "github_project": "envrx",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "envrx"
}
        
Elapsed time: 0.16733s