You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a table "messages" (model shown below) with a BIT(64) column in PostgreSQL, and I'm trying to insert or update data into that column using SQLAlchemy (via pgvector-python). However, I'm getting an error about the bit string length not matching BIT(64). I've tried all of the following formats for the data:
Bit(embedding) (expects bytes-like object)
"010101" (expects bytes-like object)
b"010101" (bit string length 528 does not match type bit(64))
b'B"010101"' (bit string length 536 does not match type bit(64))
But no matter which approach I take, I see an error similar to:
ERROR:__main__:Error processing batch: (sqlalchemy.dialects.postgresql.asyncpg.Error) <class 'asyncpg.exceptions.StringDataLengthMismatchError'>: bit string l
ength 536 does not match type bit(64)
[SQL: UPDATE messages SET message_hash=$1, updated_at=now() WHERE messages.id = $2::BIGINT]
[parameters: [(b"B'0000100101000100000101001100001100011011010111000111101111111110'", 23189), (b"B'1000100001000100000101001100011100010011001110001101101111
011110'", 724950), (b"B'1011011100000100010001111110101111001011111011010110101111011010'", 103289), (b"B'1001101100010100010001100100001101011011001111011100
101111111010'", 90)]]
(Background on this error at: https://sqlalche.me/e/20/dbapi)
ERROR:__main__:Fatal error: (sqlalchemy.dialects.postgresql.asyncpg.Error) <class 'asyncpg.exceptions.StringDataLengthMismatchError'>: bit string length 536 d
oes not match type bit(64)
or
sqlalchemy.exc.DBAPIError: (sqlalchemy.dialects.postgresql.asyncpg.Error) <class 'asyncpg.exceptions.StringDataLengthMismatchError'>: bit string length 528 does not match type bit(64)
[SQL: UPDATE messages SET message_hash=$1, updated_at=now() WHERE messages.id = $2::BIGINT]
[parameters: [(b"'0000100101000100000101001100001100011011010111000111101111111110'", 23189), (b"'1000100001000100000101001100011100010011001110001101101111011110'", 724950), (b"'1011011100000100010001111110101111001011111011010110101111011010'", 103289), (b"'1001101100010100010001100100001101011011001111011100101111111010'", 90)]]
(Background on this error at: https://sqlalche.me/e/20/dbapi)
What I Tried
Just giving a plain string of bits (e.g., "010101").
Supplying the value in a B'...' literal form.
Supplying raw bytes, like b"010101".
Using a Bit object from pgvector.utils.Bit.
Nothing seems to work, and I get the mismatch length error.
I have a table "messages" (model shown below) with a
BIT(64)
column in PostgreSQL, and I'm trying to insert or update data into that column using SQLAlchemy (viapgvector-python
). However, I'm getting an error about the bit string length not matchingBIT(64)
. I've tried all of the following formats for the data:Bit(embedding)
(expects bytes-like object)"010101"
(expects bytes-like object)b"010101"
(bit string length 528 does not match type bit(64))b'B"010101"'
(bit string length 536 does not match type bit(64))But no matter which approach I take, I see an error similar to:
or
What I Tried
"010101"
).B'...'
literal form.b"010101"
.Bit
object frompgvector.utils.Bit
.Nothing seems to work, and I get the mismatch length error.
Snippet of the Model
Code Snippet
Expected Behavior
I want to store a 64-bit value in the
BIT(64)
column without errors.Actual Behavior
PostgreSQL complains about the bit string length not matching
BIT(64)
, or asking bytes-like object.Environment
The text was updated successfully, but these errors were encountered: