Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to create table documents on postgres #407

Open
RiverFerry opened this issue Jan 26, 2024 · 1 comment
Open

how to create table documents on postgres #407

RiverFerry opened this issue Jan 26, 2024 · 1 comment

Comments

@RiverFerry
Copy link

env

export DATASTORE=postgres
export PG_HOST=localhost
export PG_PORT=5432
export PG_USER=river
export PG_DB=postgres
export PG_PASSWORD=a123456

problem

I encountered an issue while running a plugin on my local Mac. The problem arises when I try to post to an upsert API using FastAPI.

image

Below is the error that the plugin prints:

2024-01-26 17:28:53.704 | INFO | services.date:to_unix_timestamp:23 - Invalid date format: string
begin upsert pgsql.
2024-01-26 17:28:53.708 | ERROR | server.main:upsert:86 - current transaction is aborted, commands ignored until end of transaction block

This error occurs when the code executes this block: self.client.commit().
Here is the SQL query:

INSERT INTO documents (id, content, embedding, document_id, source, source_id, url, author, created_at) VALUES ('1234_0', 'fdfgvdfbfgnghnhgnghnghngh', '[-0.00477524 -0.01822915 0.00531684 ... -0.01504565 -0.01974824 -0.00251642]', '1234', 'email', 'string', 'string', 'string', '(datetime.datetime(2024, 1, 26, 17, 14, 58),)') ON CONFLICT (id) DO UPDATE SET content = 'fdfgvdfbfgnghnhgnghnghngh', embedding = '[-0.00477524 -0.01822915 0.00531684 ... -0.01504565 -0.01974824 -0.00251642]', document_id = '1234', source = 'email', source_id = 'string', url = 'string', author = 'string', created_at = '(datetime.datetime(2024, 1, 26, 17, 14, 58),)'

When I run this query in pgAdmin, it appears that the documents table does not exist.
image

I found a _create_table function in other database providers, but I couldn't find a similar function for PostgreSQL.

Could someone please help me identify the reason for this issue?

Thank you!

@RiverFerry
Copy link
Author

postgre

CREATE TABLE IF NOT EXISTS documents (
    id TEXT PRIMARY KEY,
    source TEXT,
    source_id TEXT,
    content TEXT,
    document_id TEXT,
    author TEXT,
    url TEXT,
    created_at TIMESTAMPTZ DEFAULT NOW(),
    embedding vector
);

i use this create sql, and now i can upsert successful.
but i don not know whether it is strict correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant