oddrn-generator


Nameoddrn-generator JSON
Version 0.1.103 PyPI version JSON
download
home_pagehttps://github.com/opendatadiscovery/oddrn-generator
SummaryOpen Data Discovery Resource Name Generator
upload_time2024-07-15 11:21:18
maintainerNone
docs_urlNone
authorOpen Data Discovery
requires_python<4.0,>=3.9
licenseApache-2.0
keywords oddrn opendatadiscovery
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI version](https://badge.fury.io/py/oddrn-generator.svg)](https://badge.fury.io/py/oddrn-generator)

# Open Data Discovery Resource Name Generator

Helps generate oddrn for data sources.

* [Requirements](#requirements)
* [Installation](#installation)
* [Available generators](#available-generators)
* [Generator properties](#generator-properties)
* [Generator methods](#generator-methods)
* [Generator properties](#generator-properties)
* [Example usage](#example-usage)
* [Exceptions](#example-usage)
* [Development](#development)

## Requirements

* __Python >= 3.7__

## Installation

```bash
poetry add oddrn-generator
# or
pip install oddrn-generator
```

## Usage and configuration

### Available generators
| DataSource   | Generator class name  |
|--------------|-----------------------|
| cassandra    | CassandraGenerator    |
| postgresql   | PostgresqlGenerator   |
| mysql        | MysqlGenerator        |
| glue         | GlueGenerator         |
| s3           | S3Generator           |
| kafka        | KafkaGenerator        |
| kafkaconnect | KafkaConnectGenerator |
| snowflake    | SnowflakeGenerator    |
| airflow      | AirflowGenerator      |
| hive         | HiveGenerator         |
| dynamodb     | DynamodbGenerator     |
| odbc         | OdbcGenerator         |
| mssql        | MssqlGenerator        |
| oracle       | OracleGenerator       |
| redshift     | RedshiftGenerator     |
| clickhouse   | ClickHouseGenerator   |
| athena       | AthenaGenerator       |
| quicksight   | QuicksightGenerator   |
| dbt          | DbtGenerator          |
| prefect      | PrefectGenerator      |
| tableau      | TableauGenerator      |
| neo4j        | Neo4jGenerator        |
| mongodb      | MongoGenerator        |
| vertica      | VerticaGenerator      |
| CubeJs       | CubeJsGenerator       |
| superset     | SupersetGenerator     |
| Presto       | PrestoGenerator       |
| Trino        | TrinoGenerator        |
| dms          | DmsGenerator          |
| powerbi      | PowerBiGenerator      |

### Generator properties

* base_oddrn - Get base oddrn (without path)
* available_paths - Get all available path of generator

### Generator methods

* get_oddrn_by_path(path_name, new_value=None) - Get oddrn string by path. You also can set value for this path using '
  new_value' param
* set_oddrn_paths(**kwargs) - Set or update values of oddrn path
* get_data_source_oddrn() - Get data source oddrn

### Generator parameters:

* host_settings: str - optional. Hostname configuration
* cloud_settings: dict - optional. Cloud configuration
* **kwargs - path's name and values

### Example usage

```python
# postgresql
from oddrn_generator import PostgresqlGenerator

oddrn_gen = PostgresqlGenerator(
    host_settings='my.host.com:5432',
    schemas='schema_name', databases='database_name', tables='table_name'
)

print(oddrn_gen.base_oddrn)
# //postgresql/host/my.host.com:5432
print(oddrn_gen.available_paths)
# ('databases', 'schemas', 'tables', 'views', 'tables_columns', 'views_columns', 'relationships')

print(oddrn_gen.get_data_source_oddrn())
# //postgresql/host/my.host.com:5432/databases/database_name

print(oddrn_gen.get_oddrn_by_path("schemas"))
# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name

print(oddrn_gen.get_oddrn_by_path("databases"))
# //postgresql/host/my.host.com:5432/databases/database_name

print(oddrn_gen.get_oddrn_by_path("tables"))
# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/table_name

# you can set or change path:
oddrn_gen.set_oddrn_paths(tables="another_table_name", tables_columns="new_column_name")
print(oddrn_gen.get_oddrn_by_path("tables_columns"))
# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/another_table_name/columns/new_column_name

oddrn_gen.set_oddrn_paths(relationships="references_table_2_with_constraint_fk")
print(oddrn_gen.get_oddrn_by_path("relationships"))
# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/another_table_name/relationships/references_table_2_with_constraint_fk

# you can get path wih new values:
print(oddrn_gen.get_oddrn_by_path("tables_columns", new_value="another_new_column_name"))
# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/another_table_name/columns/another_new_column_name


# glue
from oddrn_generator import GlueGenerator

oddrn_gen = GlueGenerator(
    cloud_settings={'account': 'acc_id', 'region': 'reg_id'},
    databases='database_name', tables='table_name', columns='column_name',
    jobs='job_name', runs='run_name', owners='owner_name'
)

print(oddrn_gen.available_paths)
# ('databases', 'tables', 'columns', 'owners', 'jobs', 'runs')

print(oddrn_gen.get_oddrn_by_path("databases"))
# //glue/cloud/aws/account/acc_id/region/reg_id/databases/database_name

print(oddrn_gen.get_oddrn_by_path("tables"))
# //glue/cloud/aws/account/acc_id/region/reg_id/databases/database_name/tables/table_name'

print(oddrn_gen.get_oddrn_by_path("columns"))
# //glue/cloud/aws/account/acc_id/region/reg_id/databases/database_name/tables/table_name/columns/column_name

print(oddrn_gen.get_oddrn_by_path("jobs"))
# //glue/cloud/aws/account/acc_id/region/reg_id/jobs/job_name

print(oddrn_gen.get_oddrn_by_path("runs"))
# //glue/cloud/aws/account/acc_id/region/reg_id/jobs/job_name/runs/run_name

print(oddrn_gen.get_oddrn_by_path("owners"))
# //glue/cloud/aws/account/acc_id/region/reg_id/owners/owner_name

```

### Exceptions

* WrongPathOrderException - raises when trying set path that depends on another path

```python
from oddrn_generator import PostgresqlGenerator

oddrn_gen = PostgresqlGenerator(
    host_settings='my.host.com:5432',
    schemas='schema_name', databases='database_name',
    tables_columns='column_without_table'
)
# WrongPathOrderException: 'tables_columns' can not be without 'tables' attribute
```

* EmptyPathValueException - raises when trying to get a path that is not set up

```python
from oddrn_generator import PostgresqlGenerator

oddrn_gen = PostgresqlGenerator(
    host_settings='my.host.com:5432', schemas='schema_name', databases='database_name',
)
oddrn_gen.get_oddrn_by_path("tables")

# EmptyPathValueException: Path 'tables' is not set up
```

* PathDoestExistException - raises when trying to get not existing oddrn path

```python
from oddrn_generator import PostgresqlGenerator

oddrn_gen = PostgresqlGenerator(
    host_settings='my.host.com:5432', schemas='schema_name', databases='database_name',
)
oddrn_gen.get_oddrn_by_path("jobs")

# PathDoestExistException: Path 'jobs' doesn't exist in generator
```

## Development

```bash
#Install dependencies
poetry install

#Activate shell
poetry shell

# Run tests
pytest tests/
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/opendatadiscovery/oddrn-generator",
    "name": "oddrn-generator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "oddrn, opendatadiscovery",
    "author": "Open Data Discovery",
    "author_email": "pypi@opendatadiscovery.org",
    "download_url": "https://files.pythonhosted.org/packages/b2/b7/48a0aceab312e5ae14099dd68c793c018a68acf30cbbe80a84373457d4ca/oddrn_generator-0.1.103.tar.gz",
    "platform": null,
    "description": "[![PyPI version](https://badge.fury.io/py/oddrn-generator.svg)](https://badge.fury.io/py/oddrn-generator)\n\n# Open Data Discovery Resource Name Generator\n\nHelps generate oddrn for data sources.\n\n* [Requirements](#requirements)\n* [Installation](#installation)\n* [Available generators](#available-generators)\n* [Generator properties](#generator-properties)\n* [Generator methods](#generator-methods)\n* [Generator properties](#generator-properties)\n* [Example usage](#example-usage)\n* [Exceptions](#example-usage)\n* [Development](#development)\n\n## Requirements\n\n* __Python >= 3.7__\n\n## Installation\n\n```bash\npoetry add oddrn-generator\n# or\npip install oddrn-generator\n```\n\n## Usage and configuration\n\n### Available generators\n| DataSource   | Generator class name  |\n|--------------|-----------------------|\n| cassandra    | CassandraGenerator    |\n| postgresql   | PostgresqlGenerator   |\n| mysql        | MysqlGenerator        |\n| glue         | GlueGenerator         |\n| s3           | S3Generator           |\n| kafka        | KafkaGenerator        |\n| kafkaconnect | KafkaConnectGenerator |\n| snowflake    | SnowflakeGenerator    |\n| airflow      | AirflowGenerator      |\n| hive         | HiveGenerator         |\n| dynamodb     | DynamodbGenerator     |\n| odbc         | OdbcGenerator         |\n| mssql        | MssqlGenerator        |\n| oracle       | OracleGenerator       |\n| redshift     | RedshiftGenerator     |\n| clickhouse   | ClickHouseGenerator   |\n| athena       | AthenaGenerator       |\n| quicksight   | QuicksightGenerator   |\n| dbt          | DbtGenerator          |\n| prefect      | PrefectGenerator      |\n| tableau      | TableauGenerator      |\n| neo4j        | Neo4jGenerator        |\n| mongodb      | MongoGenerator        |\n| vertica      | VerticaGenerator      |\n| CubeJs       | CubeJsGenerator       |\n| superset     | SupersetGenerator     |\n| Presto       | PrestoGenerator       |\n| Trino        | TrinoGenerator        |\n| dms          | DmsGenerator          |\n| powerbi      | PowerBiGenerator      |\n\n### Generator properties\n\n* base_oddrn - Get base oddrn (without path)\n* available_paths - Get all available path of generator\n\n### Generator methods\n\n* get_oddrn_by_path(path_name, new_value=None) - Get oddrn string by path. You also can set value for this path using '\n  new_value' param\n* set_oddrn_paths(**kwargs) - Set or update values of oddrn path\n* get_data_source_oddrn() - Get data source oddrn\n\n### Generator parameters:\n\n* host_settings: str - optional. Hostname configuration\n* cloud_settings: dict - optional. Cloud configuration\n* **kwargs - path's name and values\n\n### Example usage\n\n```python\n# postgresql\nfrom oddrn_generator import PostgresqlGenerator\n\noddrn_gen = PostgresqlGenerator(\n    host_settings='my.host.com:5432',\n    schemas='schema_name', databases='database_name', tables='table_name'\n)\n\nprint(oddrn_gen.base_oddrn)\n# //postgresql/host/my.host.com:5432\nprint(oddrn_gen.available_paths)\n# ('databases', 'schemas', 'tables', 'views', 'tables_columns', 'views_columns', 'relationships')\n\nprint(oddrn_gen.get_data_source_oddrn())\n# //postgresql/host/my.host.com:5432/databases/database_name\n\nprint(oddrn_gen.get_oddrn_by_path(\"schemas\"))\n# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name\n\nprint(oddrn_gen.get_oddrn_by_path(\"databases\"))\n# //postgresql/host/my.host.com:5432/databases/database_name\n\nprint(oddrn_gen.get_oddrn_by_path(\"tables\"))\n# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/table_name\n\n# you can set or change path:\noddrn_gen.set_oddrn_paths(tables=\"another_table_name\", tables_columns=\"new_column_name\")\nprint(oddrn_gen.get_oddrn_by_path(\"tables_columns\"))\n# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/another_table_name/columns/new_column_name\n\noddrn_gen.set_oddrn_paths(relationships=\"references_table_2_with_constraint_fk\")\nprint(oddrn_gen.get_oddrn_by_path(\"relationships\"))\n# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/another_table_name/relationships/references_table_2_with_constraint_fk\n\n# you can get path wih new values:\nprint(oddrn_gen.get_oddrn_by_path(\"tables_columns\", new_value=\"another_new_column_name\"))\n# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/another_table_name/columns/another_new_column_name\n\n\n# glue\nfrom oddrn_generator import GlueGenerator\n\noddrn_gen = GlueGenerator(\n    cloud_settings={'account': 'acc_id', 'region': 'reg_id'},\n    databases='database_name', tables='table_name', columns='column_name',\n    jobs='job_name', runs='run_name', owners='owner_name'\n)\n\nprint(oddrn_gen.available_paths)\n# ('databases', 'tables', 'columns', 'owners', 'jobs', 'runs')\n\nprint(oddrn_gen.get_oddrn_by_path(\"databases\"))\n# //glue/cloud/aws/account/acc_id/region/reg_id/databases/database_name\n\nprint(oddrn_gen.get_oddrn_by_path(\"tables\"))\n# //glue/cloud/aws/account/acc_id/region/reg_id/databases/database_name/tables/table_name'\n\nprint(oddrn_gen.get_oddrn_by_path(\"columns\"))\n# //glue/cloud/aws/account/acc_id/region/reg_id/databases/database_name/tables/table_name/columns/column_name\n\nprint(oddrn_gen.get_oddrn_by_path(\"jobs\"))\n# //glue/cloud/aws/account/acc_id/region/reg_id/jobs/job_name\n\nprint(oddrn_gen.get_oddrn_by_path(\"runs\"))\n# //glue/cloud/aws/account/acc_id/region/reg_id/jobs/job_name/runs/run_name\n\nprint(oddrn_gen.get_oddrn_by_path(\"owners\"))\n# //glue/cloud/aws/account/acc_id/region/reg_id/owners/owner_name\n\n```\n\n### Exceptions\n\n* WrongPathOrderException - raises when trying set path that depends on another path\n\n```python\nfrom oddrn_generator import PostgresqlGenerator\n\noddrn_gen = PostgresqlGenerator(\n    host_settings='my.host.com:5432',\n    schemas='schema_name', databases='database_name',\n    tables_columns='column_without_table'\n)\n# WrongPathOrderException: 'tables_columns' can not be without 'tables' attribute\n```\n\n* EmptyPathValueException - raises when trying to get a path that is not set up\n\n```python\nfrom oddrn_generator import PostgresqlGenerator\n\noddrn_gen = PostgresqlGenerator(\n    host_settings='my.host.com:5432', schemas='schema_name', databases='database_name',\n)\noddrn_gen.get_oddrn_by_path(\"tables\")\n\n# EmptyPathValueException: Path 'tables' is not set up\n```\n\n* PathDoestExistException - raises when trying to get not existing oddrn path\n\n```python\nfrom oddrn_generator import PostgresqlGenerator\n\noddrn_gen = PostgresqlGenerator(\n    host_settings='my.host.com:5432', schemas='schema_name', databases='database_name',\n)\noddrn_gen.get_oddrn_by_path(\"jobs\")\n\n# PathDoestExistException: Path 'jobs' doesn't exist in generator\n```\n\n## Development\n\n```bash\n#Install dependencies\npoetry install\n\n#Activate shell\npoetry shell\n\n# Run tests\npytest tests/\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Open Data Discovery Resource Name Generator",
    "version": "0.1.103",
    "project_urls": {
        "Homepage": "https://github.com/opendatadiscovery/oddrn-generator",
        "Repository": "https://github.com/opendatadiscovery/oddrn-generator"
    },
    "split_keywords": [
        "oddrn",
        " opendatadiscovery"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "015087b063886b607d1682836cf14ca7ea000acc8cbf9a4c9535b461ae01c713",
                "md5": "55e40c9bde75f634b2bd4be104345a8b",
                "sha256": "a81dbd9a3b91c9e34182b42ec0412f72fa64d543b747dff67269a65bfd1503f2"
            },
            "downloads": -1,
            "filename": "oddrn_generator-0.1.103-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "55e40c9bde75f634b2bd4be104345a8b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 21607,
            "upload_time": "2024-07-15T11:21:15",
            "upload_time_iso_8601": "2024-07-15T11:21:15.955147Z",
            "url": "https://files.pythonhosted.org/packages/01/50/87b063886b607d1682836cf14ca7ea000acc8cbf9a4c9535b461ae01c713/oddrn_generator-0.1.103-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b2b748a0aceab312e5ae14099dd68c793c018a68acf30cbbe80a84373457d4ca",
                "md5": "7813318fa0dfa40c0d45c13fb316a6c5",
                "sha256": "5b490b5e0ea2b6fa8aed3ceb6817e0a9190f9841ccfb493e45eae8f240cdd5b5"
            },
            "downloads": -1,
            "filename": "oddrn_generator-0.1.103.tar.gz",
            "has_sig": false,
            "md5_digest": "7813318fa0dfa40c0d45c13fb316a6c5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 17985,
            "upload_time": "2024-07-15T11:21:18",
            "upload_time_iso_8601": "2024-07-15T11:21:18.301928Z",
            "url": "https://files.pythonhosted.org/packages/b2/b7/48a0aceab312e5ae14099dd68c793c018a68acf30cbbe80a84373457d4ca/oddrn_generator-0.1.103.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-15 11:21:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "opendatadiscovery",
    "github_project": "oddrn-generator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "oddrn-generator"
}
        
Elapsed time: 0.34656s