{"id":15481671,"url":"https://github.com/starkgang/envrx","last_synced_at":"2026-04-09T12:17:03.181Z","repository":{"id":213135557,"uuid":"732725263","full_name":"StarkGang/EnvrX","owner":"StarkGang","description":"A resilient method to handle environment variables with support for leading databases and three different file formats.","archived":false,"fork":false,"pushed_at":"2023-12-23T12:06:22.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-19T05:16:55.435Z","etag":null,"topics":["env","environment-variables","json","mongodb","redis","sql","sqlite3","variables","yaml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StarkGang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-17T16:24:40.000Z","updated_at":"2024-06-15T05:02:25.000Z","dependencies_parsed_at":"2023-12-18T18:45:38.361Z","dependency_job_id":"2993a625-3011-4c3f-9a3c-c5b2bf46c07e","html_url":"https://github.com/StarkGang/EnvrX","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"13ad1fb352718955f5a0feefa4bb2c781441d81a"},"previous_names":["starkgang/envrx"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarkGang%2FEnvrX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarkGang%2FEnvrX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarkGang%2FEnvrX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarkGang%2FEnvrX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StarkGang","download_url":"https://codeload.github.com/StarkGang/EnvrX/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246046146,"owners_count":20714912,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["env","environment-variables","json","mongodb","redis","sql","sqlite3","variables","yaml"],"created_at":"2024-10-02T05:05:26.612Z","updated_at":"2025-10-13T21:37:27.544Z","avatar_url":"https://github.com/StarkGang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarkgang%2Fenvrx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstarkgang%2Fenvrx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarkgang%2Fenvrx/lists"}