Closed sh-at-cs closed 2 months ago
Thanks for the report. A PR with a change to pandas-stubs/io/sql.pyi
is welcome.
For tests, we use sqllite3
. Not sure if your example will work with that. If so, then PR should include a test in test_io.py
in function test_read_sql_query()
. If not, then it's OK to do a PR without a test.
Describe the bug The type for
pandas.read_sql_query
is specified bypandas-stubs
as a dictionary mapping fromstr
tostr | bytes | date | timedelta | datetime64 | timedelta64 | int | float | complex
. But for some database drivers likepsycopg2
ormysql-connector
, it's also possible to pass in tuples e.g. as the right-hand side ofIN
conditions (WHERE ... IN (1, 2, 3)
).To Reproduce A minimal example using Postgres (it looks similar for MySQL except the parameter is written as
:ids
in the query):docker run -p 9876:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres
IN
conditions work fine (I included PEP 723 script metadata so you can just douv run
orpipx run
on it to avoid needing to install dependencies manually):Output is as expected:
Please complete the following information:
pandas-stubs
: 2.2.2.240909Additional context Something like this doesn't work for
sqlite3
connections, because it really does only accept "primitive" values for substitutions.But IMO it doesn't make sense to restrict the set of allowed types to the universally supported subset, because some other weird database could decide to not even support
int
substitutions or something like that and then even the current set wouldn't be valid.