GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Cannot Insert or Update Data into a `bit(64)` in SQLAlchemy · Issue #112 · pgvector/pgvector-python Closed DescriptionI have a table "messages" (model shown below) with a
But no matter which approach I take, I see an error similar to: or What I Tried
Nothing seems to work, and I get the mismatch length error. Snippet of the Model from pgvector.sqlalchemy import BIT from pgvector.utils import Bit class Messages(Base): __tablename__ = "messages" id: Mapped[int] = mapped_column(BigInteger, primary_key=True) # other columns... message_hash: Mapped[np.ndarray | None] = mapped_column(BIT(64), nullable=True) Code Snippet assert embeddings_hash.ndim == 1, f"{embeddings_hash.shape=}" assert embeddings_hash.shape[0] == len(batch), f"{embeddings_hash.shape=} {len(batch)=}" assert embeddings_hash.dtype == np.uint64, f"{embeddings_hash.dtype=}" embeddings_hash = embeddings_hash.view(np.uint8) # shape = (batch_size * 8,) embeddings_hash = embeddings_hash.reshape(configuration["batch_size"], 8) embeddings_hash = np.unpackbits(embeddings_hash, axis=1) updates = [ { "b_id": message.id, "message_hash": f"B'{Bit(embedding_hash.reshape(-1)).to_text()}'".encode("ascii") } for message, embedding_hash in zip(batch, embeddings_hash) ] await session.execute( Messages.__table__.update() .where(Messages.id == bindparam("b_id")) .values({"message_hash": bindparam("message_hash")}) .execution_options(synchronize_session=False), updates ) Expected Behavior Actual Behavior Environment
Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |