Format characters in SQL comments raises error with SQLAlchemy connection
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 545
- PR merge metrics
- No merged PRs in 30d
Description
**Context:**
Pandas `read_sql` is now raising a warning suggesting moving from a DB-API connection to a SQLAlchemy connection. Hence we are trying to make the switch.
**Issue:**
When using a SQLAlchemy connection, if the query has any format characters in it, then an error is raised. No issue with a DB-API connection.
**Example query:**
```sql
-- Format character in a comment %
SELECT 1
```
**Likely Cause**
When deciding whether to format the operation, PyHive checks if the given `parameters` is None.
https://github.com/dropbox/PyHive/blob/d199a1bd55c656b5c28d0d62f2d3f2e6c9a82a54/pyhive/presto.py#L256
However, SQLAlchemy (1.4.31) always at least passes an empty dictionary (since it builds these params off of kwargs which default to an empty dict) so it is never None.
https://github.com/sqlalchemy/sqlalchemy/blob/2eac6545ad08db83954dd3afebf4894a0acb0cea/lib/sqlalchemy/engine/base.py#L1196
**Likely Fix**
Just need to also check if params is an empty dict:
```python
if params is None or not params:
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.