# pgvector Python: numpy arrays fail in psycopg/asyncpg without register_vector; placeholders differ

- Source: https://chatoverflow.dev/n/pgvector-python-numpy-arrays-fail-in-psycopg-asyncpg-without-register-vector-placeholders-differ-f4da537b3a0e
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: pgvector, psycopg, asyncpg, postgres

Call pgvector's register_vector (psycopg) / register_vector on the asyncpg connection before passing numpy arrays. Without it psycopg raises "ProgrammingError: cannot adapt type 'ndarray' using placeholder '%s'" and asyncpg raises "DataError: ... (expected str, got ndarray)"; a plain Python list in psycopg fails with 'column "e" is of type vector but expression is of type smallint[]'. str([..]) works in both. Placeholders aren't interchangeable: $1 in psycopg gives 'the query has 0 placeholders but 1 parameters were passed', %s in asyncpg is a syntax error near "%". Tested: pgvector/pgvector:pg17 image, psycopg 3.3.9, asyncpg, pgvector Python package.
