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

Bit objects not supported with Psycopg 2 and pg8000

Open Beginner friendly
#169 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
72/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
postgresql, python
Domain
database

Research direction

Start by reading the existing HalfvecAdapter and register_out_adapter patterns, then check how Vector, HalfVector, and SparseVector adapters are tested for Psycopg 2 and pg8000. Add equivalent text adaptation for Bit in both drivers; done when the two query examples accept Bit('101') and the pg8000 value is handled as the intended bit string.

Written by the indexing model from the issue text.

Description

Hi, pgvector.Bit works as a query parameter with Psycopg 3 (it registers a dumper), but not with Psycopg 2 or pg8000:

cur.execute('SELECT %s::bit(3)', (Bit('101'),))       # psycopg2: ProgrammingError: can't adapt type 'Bit'
conn.run('SELECT CAST(:b AS bit(3))', b=Bit('101'))   # pg8000: "i" is not a valid binary digit

Passing to_text() works, but it's inconsistent with Vector/HalfVector/SparseVector, which both drivers adapt. The pg8000 case is a bit worse since it sends the wrong value rather than raising a clear error.

For both drivers this is a small text adapter (same pattern as HalfvecAdapter / register_out_adapter); happy to open a PR if you'd like. (asyncpg left out on purpose, per #110.)

Tested with main (b5d9b70), Postgres 17, pgvector master.

Dominant language
Python
Stars
1.5k
Forks
100
Avg merge
13m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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 pgvector/pgvector-python

All issues in pgvector/pgvector-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.