Skip to content

Postgres

PostgresDocumentStore #

Bases: KVDocumentStore

Postgres文档(Node)存储。

用于文档和节点对象的Postgres存储。

Source code in llama_index/storage/docstore/postgres/base.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
class PostgresDocumentStore(KVDocumentStore):
    """Postgres文档(Node)存储。

    用于文档和节点对象的Postgres存储。

    Args:
        postgres_kvstore(PostgresKVStore):Postgres键值存储
        命名空间(str):文档存储的命名空间
        batch_size(int):批量操作的批量大小"""

    def __init__(
        self,
        postgres_kvstore: PostgresKVStore,
        namespace: Optional[str] = None,
        batch_size: int = DEFAULT_BATCH_SIZE,
    ) -> None:
        """初始化一个PostgresDocumentStore。"""
        super().__init__(postgres_kvstore, namespace=namespace, batch_size=batch_size)

    @classmethod
    def from_uri(
        cls,
        uri: str,
        namespace: Optional[str] = None,
        table_name: str = "docstore",
        schema_name: str = "public",
        perform_setup: bool = True,
        debug: bool = False,
        use_jsonb: bool = False,
    ) -> "PostgresDocumentStore":
        """从Postgres URI加载一个PostgresDocumentStore。"""
        postgres_kvstore = PostgresKVStore.from_uri(
            uri=uri,
            table_name=table_name,
            schema_name=schema_name,
            perform_setup=perform_setup,
            debug=debug,
            use_jsonb=use_jsonb,
        )
        return cls(postgres_kvstore, namespace)

    @classmethod
    def from_params(
        cls,
        host: Optional[str] = None,
        port: Optional[str] = None,
        database: Optional[str] = None,
        user: Optional[str] = None,
        password: Optional[str] = None,
        namespace: Optional[str] = None,
        table_name: str = "docstore",
        schema_name: str = "public",
        perform_setup: bool = True,
        debug: bool = False,
        use_jsonb: bool = False,
    ) -> "PostgresDocumentStore":
        """从Postgres主机和端口加载一个PostgresDocumentStore。"""
        postgres_kvstore = PostgresKVStore.from_params(
            host=host,
            port=port,
            database=database,
            user=user,
            password=password,
            table_name=table_name,
            schema_name=schema_name,
            perform_setup=perform_setup,
            debug=debug,
            use_jsonb=use_jsonb,
        )
        return cls(postgres_kvstore, namespace)

from_uri classmethod #

from_uri(
    uri: str,
    namespace: Optional[str] = None,
    table_name: str = "docstore",
    schema_name: str = "public",
    perform_setup: bool = True,
    debug: bool = False,
    use_jsonb: bool = False,
) -> PostgresDocumentStore

从Postgres URI加载一个PostgresDocumentStore。

Source code in llama_index/storage/docstore/postgres/base.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@classmethod
def from_uri(
    cls,
    uri: str,
    namespace: Optional[str] = None,
    table_name: str = "docstore",
    schema_name: str = "public",
    perform_setup: bool = True,
    debug: bool = False,
    use_jsonb: bool = False,
) -> "PostgresDocumentStore":
    """从Postgres URI加载一个PostgresDocumentStore。"""
    postgres_kvstore = PostgresKVStore.from_uri(
        uri=uri,
        table_name=table_name,
        schema_name=schema_name,
        perform_setup=perform_setup,
        debug=debug,
        use_jsonb=use_jsonb,
    )
    return cls(postgres_kvstore, namespace)

from_params classmethod #

from_params(
    host: Optional[str] = None,
    port: Optional[str] = None,
    database: Optional[str] = None,
    user: Optional[str] = None,
    password: Optional[str] = None,
    namespace: Optional[str] = None,
    table_name: str = "docstore",
    schema_name: str = "public",
    perform_setup: bool = True,
    debug: bool = False,
    use_jsonb: bool = False,
) -> PostgresDocumentStore

从Postgres主机和端口加载一个PostgresDocumentStore。

Source code in llama_index/storage/docstore/postgres/base.py
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@classmethod
def from_params(
    cls,
    host: Optional[str] = None,
    port: Optional[str] = None,
    database: Optional[str] = None,
    user: Optional[str] = None,
    password: Optional[str] = None,
    namespace: Optional[str] = None,
    table_name: str = "docstore",
    schema_name: str = "public",
    perform_setup: bool = True,
    debug: bool = False,
    use_jsonb: bool = False,
) -> "PostgresDocumentStore":
    """从Postgres主机和端口加载一个PostgresDocumentStore。"""
    postgres_kvstore = PostgresKVStore.from_params(
        host=host,
        port=port,
        database=database,
        user=user,
        password=password,
        table_name=table_name,
        schema_name=schema_name,
        perform_setup=perform_setup,
        debug=debug,
        use_jsonb=use_jsonb,
    )
    return cls(postgres_kvstore, namespace)