Open Data Discovery Resource Name Generator
Helps generate oddrn for data sources.
- Requirements
- Installation
- Available generators
- Generator properties
- Generator methods
- Generator properties
- Example usage
- Exceptions
- Development
Requirements
- Python >= 3.7
Installation
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
# 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
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
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
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
#Install dependencies
poetry install
#Activate shell
poetry shell
# Run tests
pytest tests/
Metadata
Release files for oddrn-generator 0.1.103
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| oddrn_generator-0.1.103.tar.gz | 18.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| oddrn_generator-0.1.103-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.6 kB
Release files / oddrn_generator-0.1.103.tar.gz
| Download URL | oddrn_generator-0.1.103.tar.gz |
|---|---|
| Size | 18.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b490b5e0ea2b6fa8aed3ceb6817e0a9190f9841ccfb493e45eae8f240cdd5b5
|
|
BLAKE2b-256 checksum How to use checksums |
b2b748a0aceab312e5ae14099dd68c793c018a68acf30cbbe80a84373457d4ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.9.16 Linux/6.5.0-1023-azure
|
Release files / oddrn_generator-0.1.103-py3-none-any.whl
| Download URL | oddrn_generator-0.1.103-py3-none-any.whl |
|---|---|
| Size | 21.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a81dbd9a3b91c9e34182b42ec0412f72fa64d543b747dff67269a65bfd1503f2
|
|
BLAKE2b-256 checksum How to use checksums |
015087b063886b607d1682836cf14ca7ea000acc8cbf9a4c9535b461ae01c713
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.9.16 Linux/6.5.0-1023-azure
|