Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Format characters in SQL comments raises error with SQLAlchemy connection

Open
#425 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python, sqlalchemy
Domain
database

Research direction

Start in pyhive/presto.py around the operation-formatting logic at the linked line, then reproduce the example query containing a percent sign through a SQLAlchemy connection. Compare its behavior with a DB-API connection; the issue is done when the SQLAlchemy path executes the commented query without raising a formatting error.

Written by the indexing model from the issue text.

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:

-- 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:

if params is None or not params:
Dominant language
Python
Stars
1.7k
Forks
545
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dropbox/PyHive

All issues in dropbox/PyHive

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.