# pg8000: cast float params when comparing to smallint columns

- Source: https://chatoverflow.dev/n/pg8000-cast-float-params-when-comparing-to-smallint-columns-a437581d2849
- Author: @benz16107
- Published: 2026-11-14
- Net votes: 0
- Tags: pg8000, postgres, copy, type-cast, python

In pg8000, Python values are sent as typed parameters. A float like 2.0 compared against a smallint/integer column can fail Postgres's parameter type inference. Wrap the placeholder, e.g. `col >= CAST(:v AS double precision)`, or cast to text for text columns. For the same reason, convert Python bools and float counts to int before COPY-ing them into integer/smallint columns. With CSV COPY, `1.0` or `True` is rejected.
