Skip to content

Conversation

@FFengIll
Copy link

@FFengIll FFengIll commented Sep 18, 2023

MENTION: we can not ignore the primary key (e.g. id) via pgvector now.

from sqlmodel import Column, Field, Session, SQLModel, create_engine, select

class Item(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another approach is

id: int = Field(primary_key=True, sa_column_kwargs={"autoincrement": True})

They both seem to have same effect, from what I can tell, so maybe something is autoincrementing behind the scenes.

Copy link

@pamelafox pamelafox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this change is needed, as the current code produces an error.

@FFengIll FFengIll force-pushed the feat/sqlmodel-sample branch from a3e08bb to c6b11aa Compare February 28, 2024 13:14
@FFengIll
Copy link
Author

FFengIll commented Feb 28, 2024

I agree that this change is needed, as the current code produces an error.

I have updated which resolved the conflict.
Will PR to be merged or Closed? @pamelafox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants