py-data-api icon indicating copy to clipboard operation
py-data-api copied to clipboard

Support a URI attribute from created engine

Open jameshgrn opened this issue 5 years ago • 6 comments

Is your feature request related to a problem? Please describe. SQL Alchemy allows users to grab the URI of the sql engine (sql_engine.url) for example. Some packages require the URI instead of an engine object.

Describe the solution you'd like I would like the engine created to have a URI attribute that returns the string representation of the connection

Describe alternatives you've considered No way to get past this as far as I can tell.

jameshgrn avatar Dec 16 '20 17:12 jameshgrn

@jameshgrn Thank you for creating this issue.

I don't know the feature. Would you please show me an example or SQL Alchemy reference document? implementation of other libraries may help us.

The engine has 'url' attribute. What did you expect to return it?

engine = create_engine( 'mysql+pydataapi://', connect_args={ 'resource_arn': 'arn:aws:rds:us-east-1:123456789012:cluster:dummy',  'secret_arn': 'arn:aws:secretsmanager:us-east-1:123456789012:secret:dummy', 
'database': 'test'} )
print(engine.url)
# mysql+pydataapi://

koxudaxi avatar Dec 18 '20 02:12 koxudaxi

@koxudaxi thank you for the package! It's great

I'm thinking of this example

https://github.com/zzzeek/sqlalchemy/blob/a8f51f3c11f3cb2e344732cf3abb371f03ed30d8/lib/sqlalchemy/engine/base.py#L2501

where the engine class has an attribute 'url'

jameshgrn avatar Dec 19 '20 20:12 jameshgrn

@jameshgrn Thank you for the link.

What URL should I set? My idea is this. {db_type}+pydataapi://{resouse_arn}/{secret_arn}/{database}

Example: mysql+pydataapi://arn:aws:rds:us-east-1:123456789012:cluster:dummy/arn:aws:secretsmanager:us-east-1:123456789012:secret:dummy/test

Or, Did you expect traditional DB URI? Example: mysql://fed_user@remote_host:9306/federated/test_table

koxudaxi avatar Dec 20 '20 16:12 koxudaxi

I'm not sure, let's try the traditional DB URI?

jameshgrn avatar Dec 21 '20 21:12 jameshgrn

Following up, let me try each of these out in a use case and get back to you

jameshgrn avatar Dec 22 '20 04:12 jameshgrn

@jameshgrn I'm trying to add url attribute. But, I don't know how to set the value on the created engine.
I keep working on it.

koxudaxi avatar Dec 23 '20 09:12 koxudaxi