laughingman7743 / PyAthena

PyAthena is a Python DB API 2.0 (PEP 249) client for Amazon Athena.
MIT License
456 stars 102 forks source link

Feature request: support for positional parameter substitution #545

Open paulgrow-octane opened 1 month ago

paulgrow-octane commented 1 month ago

Thank you for a wonderful library and for your work maintaining it!

One feature I hope can be considered for future development is implementing ? style param support. Athena supports parameterized queries using the ? character for positional substitution.

For use cases where queries are run both using pyathena and by analysts directly, having PyFormat-style params is not ideal as it requires analysts to modify queries to execute them directly in their SQL clients or in the Athena console. Supporting ? for query parameterization would decouple the query from any specific execution context, making it more portable.

Thanks for your time and consideration.

laughingman7743 commented 1 month ago

https://github.com/laughingman7743/PyAthena/blob/master/pyathena/__init__.py#L19 https://github.com/laughingman7743/PyAthena/blob/master/pyathena/common.py#L557-L566 If the paramstyle is set to qmark, I think it can be handled by simply stopping the expansion of the query parameters and passing the parameters to the start_query_execution request. I think this could be easily implemented without major changes. I will probably address this eventually when I have time.