hey there - database URLs do support query string parameters, however they have a specific meaning which is that they are consumed by the DBAPI in use, not the dialect directly. Please review the docs at https://docs.sqlalchemy.org/en/14/core/engines.html#custom-dbapi-connect-arguments-on-connect-routines for background on how these arguments are used.
On Thu, Jan 6, 2022, at 8:48 AM, [email protected] wrote: > Hi ! > > While working on some improvements to PyAthena, I was looking into means to > pass some parameters to the dialect. Going through the code of the > `create_engine()` function code, I saw that dialects `__init__()` where given > dialect kwargs passed as kwargs > <https://github.com/sqlalchemy/sqlalchemy/blob/db85d28a857945ce021e27a187a14999eeb5c89e/lib/sqlalchemy/engine/create.py#L480-L482> > to the create_engine() function. But the dialect does not have access to the > connection URL. > > E.g. you can do: > > e = create_engine('<url>', dialect_kwarg1=<value>, dialect_kwarg2='<value>', > ...) > > But not: > > e = create_engine('<url>?dialect_kwarg1=<value>&dialect_kwarg2=<value>', ...) > # or > e = create_engine('<url>?kwarg1=<value>&kwarg2=<value>', ...) > # though I guess cause you can pass other kind of args, like pool args, you'd > like to keep # the `<dialect>_` prefix > > I was wondering why? Particularly given that since the connection URL is what > determines the dialect, keeping dialect specific stuff in the URL does not > seem that far fetch. Or am I overlooking something? > > Why does it matters? I find that passing arguments through the URL very > handy. Allows to easily override certain configuration parameters, with > touching any code. It also makes it easy to exchange settings with other > people. > > If there are no particular reasons to not do this, would you accept a PR to > deal with this? > > Thanks, > Nicolas. > > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/f185f29c-9ec2-48b8-a5de-fe6112ab25c5n%40googlegroups.com > > <https://groups.google.com/d/msgid/sqlalchemy/f185f29c-9ec2-48b8-a5de-fe6112ab25c5n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/01b9d50b-73d4-4fae-8a32-1993a5923743%40www.fastmail.com.
