Storage¶
Base classes and types for persistent key-value stores.
Stores enable persistence and memory that can be shared across threads, scoped to user IDs, assistant IDs, or other arbitrary namespaces.
Item
¶
Represents a stored item with metadata.
Parameters:
-
value
(
) –dict [str ,Any ]The stored data as a dictionary. Keys are filterable.
-
key
(
) –str Unique identifier within the namespace.
-
namespace
(
) –tuple [str , ...]Hierarchical path defining the collection in which this document resides. Represented as a tuple of strings, allowing for nested categorization. For example: ("documents", 'user123')
-
created_at
(
) –datetime Timestamp of item creation.
-
updated_at
(
) –datetime Timestamp of last update.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
GetOp
¶
Bases:
Operation to retrieve an item by namespace and key.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
SearchOp
¶
Bases:
Operation to search for items within a namespace prefix.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
namespace_prefix: tuple[str, ...]
instance-attribute
¶
Hierarchical path prefix to search within.
filter: Optional[dict[str, Any]] = None
class-attribute
instance-attribute
¶
Key-value pairs to filter results.
limit: int = 10
class-attribute
instance-attribute
¶
Maximum number of items to return.
offset: int = 0
class-attribute
instance-attribute
¶
Number of items to skip before returning results.
PutOp
¶
Bases:
Operation to store, update, or delete an item.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
namespace: tuple[str, ...]
instance-attribute
¶
Hierarchical path for the item.
Represented as a tuple of strings, allowing for nested categorization. For example: ("documents", "user123")
key: str
instance-attribute
¶
Unique identifier for the document.
Should be distinct within its namespace.
value: Optional[dict[str, Any]]
instance-attribute
¶
Data to be stored, or None to delete the item.
Schema: - Should be a dictionary where: - Keys are strings representing field names - Values can be of any serializable type - If None, it indicates that the item should be deleted
MatchCondition
¶
ListNamespacesOp
¶
Bases:
Operation to list namespaces with optional match conditions.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
match_conditions: Optional[tuple[MatchCondition, ...]] = None
class-attribute
instance-attribute
¶
A tuple of match conditions to apply to namespaces.
max_depth: Optional[int] = None
class-attribute
instance-attribute
¶
Return namespaces up to this depth in the hierarchy.
limit: int = 100
class-attribute
instance-attribute
¶
Maximum number of namespaces to return.
offset: int = 0
class-attribute
instance-attribute
¶
Number of namespaces to skip before returning results.
InvalidNamespaceError
¶
BaseStore
¶
Bases:
Abstract base class for persistent key-value stores.
Stores enable persistence and memory that can be shared across threads, scoped to user IDs, assistant IDs, or other arbitrary namespaces.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
|
batch(ops: Iterable[Op]) -> list[Result]
abstractmethod
¶
Execute multiple operations synchronously in a single batch.
Parameters:
-
ops
(
) –Iterable [Op ]An iterable of operations to execute.
Returns:
-
–list [Result ]A list of results, where each result corresponds to an operation in the input.
-
–list [Result ]The order of results matches the order of input operations.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
abatch(ops: Iterable[Op]) -> list[Result]
abstractmethod
async
¶
Execute multiple operations asynchronously in a single batch.
Parameters:
-
ops
(
) –Iterable [Op ]An iterable of operations to execute.
Returns:
-
–list [Result ]A list of results, where each result corresponds to an operation in the input.
-
–list [Result ]The order of results matches the order of input operations.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
get(namespace: tuple[str, ...], key: str) -> Optional[Item]
¶
Retrieve a single item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
Returns:
-
–Optional [Item ]The retrieved item or None if not found.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
search(namespace_prefix: tuple[str, ...], /, *, filter: Optional[dict[str, Any]] = None, limit: int = 10, offset: int = 0) -> list[Item]
¶
Search for items within a namespace prefix.
Parameters:
-
namespace_prefix
(
) –tuple [str , ...]Hierarchical path prefix to search within.
-
filter
(
, default:Optional [dict [str ,Any ]]None
) –Key-value pairs to filter results.
-
limit
(
, default:int 10
) –Maximum number of items to return.
-
offset
(
, default:int 0
) –Number of items to skip before returning results.
Returns:
-
–list [Item ]List of items matching the search criteria.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
put(namespace: tuple[str, ...], key: str, value: dict[str, Any]) -> None
¶
Store or update an item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
-
value
(
) –dict [str ,Any ]Dictionary containing the item's data.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
delete(namespace: tuple[str, ...], key: str) -> None
¶
Delete an item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
list_namespaces(*, prefix: Optional[NameSpacePath] = None, suffix: Optional[NameSpacePath] = None, max_depth: Optional[int] = None, limit: int = 100, offset: int = 0) -> list[tuple[str, ...]]
¶
List and filter namespaces in the store.
Used to explore the organization of data, find specific collections, or navigate the namespace hierarchy.
Parameters:
-
prefix
(
, default:Optional [Tuple [str , ...]]None
) –Filter namespaces that start with this path.
-
suffix
(
, default:Optional [Tuple [str , ...]]None
) –Filter namespaces that end with this path.
-
max_depth
(
, default:Optional [int ]None
) –Return namespaces up to this depth in the hierarchy. Namespaces deeper than this level will be truncated to this depth.
-
limit
(
, default:int 100
) –Maximum number of namespaces to return (default 100).
-
offset
(
, default:int 0
) –Number of namespaces to skip for pagination (default 0).
Returns:
-
–list [tuple [str , ...]]List[Tuple[str, ...]]: A list of namespace tuples that match the criteria.
-
–list [tuple [str , ...]]Each tuple represents a full namespace path up to
max_depth
.
Examples:
Setting max_depth=3. Given the namespaces:
# ("a", "b", "c")
# ("a", "b", "d", "e")
# ("a", "b", "d", "i")
# ("a", "b", "f")
# ("a", "c", "f")
store.list_namespaces(prefix=("a", "b"), max_depth=3)
# [("a", "b", "c"), ("a", "b", "d"), ("a", "b", "f")]
Source code in libs/checkpoint/langgraph/store/base/__init__.py
aget(namespace: tuple[str, ...], key: str) -> Optional[Item]
async
¶
Asynchronously retrieve a single item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
Returns:
-
–Optional [Item ]The retrieved item or None if not found.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
asearch(namespace_prefix: tuple[str, ...], /, *, filter: Optional[dict[str, Any]] = None, limit: int = 10, offset: int = 0) -> list[Item]
async
¶
Asynchronously search for items within a namespace prefix.
Parameters:
-
namespace_prefix
(
) –tuple [str , ...]Hierarchical path prefix to search within.
-
filter
(
, default:Optional [dict [str ,Any ]]None
) –Key-value pairs to filter results.
-
limit
(
, default:int 10
) –Maximum number of items to return.
-
offset
(
, default:int 0
) –Number of items to skip before returning results.
Returns:
-
–list [Item ]List of items matching the search criteria.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
aput(namespace: tuple[str, ...], key: str, value: dict[str, Any]) -> None
async
¶
Asynchronously store or update an item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
-
value
(
) –dict [str ,Any ]Dictionary containing the item's data.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
adelete(namespace: tuple[str, ...], key: str) -> None
async
¶
Asynchronously delete an item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
alist_namespaces(*, prefix: Optional[NameSpacePath] = None, suffix: Optional[NameSpacePath] = None, max_depth: Optional[int] = None, limit: int = 100, offset: int = 0) -> list[tuple[str, ...]]
async
¶
List and filter namespaces in the store asynchronously.
Used to explore the organization of data, find specific collections, or navigate the namespace hierarchy.
Parameters:
-
prefix
(
, default:Optional [Tuple [str , ...]]None
) –Filter namespaces that start with this path.
-
suffix
(
, default:Optional [Tuple [str , ...]]None
) –Filter namespaces that end with this path.
-
max_depth
(
, default:Optional [int ]None
) –Return namespaces up to this depth in the hierarchy. Namespaces deeper than this level will be truncated to this depth.
-
limit
(
, default:int 100
) –Maximum number of namespaces to return (default 100).
-
offset
(
, default:int 0
) –Number of namespaces to skip for pagination (default 0).
Returns:
-
–list [tuple [str , ...]]List[Tuple[str, ...]]: A list of namespace tuples that match the criteria.
-
–list [tuple [str , ...]]Each tuple represents a full namespace path up to
max_depth
.
Examples:
Setting max_depth=3. Given the namespaces:
# ("a", "b", "c")
# ("a", "b", "d", "e")
# ("a", "b", "d", "i")
# ("a", "b", "f")
# ("a", "c", "f")
await store.alist_namespaces(prefix=("a", "b"), max_depth=3)
# [("a", "b", "c"), ("a", "b", "d"), ("a", "b", "f")]
Source code in libs/checkpoint/langgraph/store/base/__init__.py
AsyncPostgresStore
¶
Bases:
,
Source code in libs/checkpoint-postgres/langgraph/store/postgres/aio.py
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
get(namespace: tuple[str, ...], key: str) -> Optional[Item]
¶
Retrieve a single item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
Returns:
-
–Optional [Item ]The retrieved item or None if not found.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
search(namespace_prefix: tuple[str, ...], /, *, filter: Optional[dict[str, Any]] = None, limit: int = 10, offset: int = 0) -> list[Item]
¶
Search for items within a namespace prefix.
Parameters:
-
namespace_prefix
(
) –tuple [str , ...]Hierarchical path prefix to search within.
-
filter
(
, default:Optional [dict [str ,Any ]]None
) –Key-value pairs to filter results.
-
limit
(
, default:int 10
) –Maximum number of items to return.
-
offset
(
, default:int 0
) –Number of items to skip before returning results.
Returns:
-
–list [Item ]List of items matching the search criteria.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
put(namespace: tuple[str, ...], key: str, value: dict[str, Any]) -> None
¶
Store or update an item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
-
value
(
) –dict [str ,Any ]Dictionary containing the item's data.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
delete(namespace: tuple[str, ...], key: str) -> None
¶
Delete an item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
list_namespaces(*, prefix: Optional[NameSpacePath] = None, suffix: Optional[NameSpacePath] = None, max_depth: Optional[int] = None, limit: int = 100, offset: int = 0) -> list[tuple[str, ...]]
¶
List and filter namespaces in the store.
Used to explore the organization of data, find specific collections, or navigate the namespace hierarchy.
Parameters:
-
prefix
(
, default:Optional [Tuple [str , ...]]None
) –Filter namespaces that start with this path.
-
suffix
(
, default:Optional [Tuple [str , ...]]None
) –Filter namespaces that end with this path.
-
max_depth
(
, default:Optional [int ]None
) –Return namespaces up to this depth in the hierarchy. Namespaces deeper than this level will be truncated to this depth.
-
limit
(
, default:int 100
) –Maximum number of namespaces to return (default 100).
-
offset
(
, default:int 0
) –Number of namespaces to skip for pagination (default 0).
Returns:
-
–list [tuple [str , ...]]List[Tuple[str, ...]]: A list of namespace tuples that match the criteria.
-
–list [tuple [str , ...]]Each tuple represents a full namespace path up to
max_depth
.
Examples:
Setting max_depth=3. Given the namespaces:
# ("a", "b", "c")
# ("a", "b", "d", "e")
# ("a", "b", "d", "i")
# ("a", "b", "f")
# ("a", "c", "f")
store.list_namespaces(prefix=("a", "b"), max_depth=3)
# [("a", "b", "c"), ("a", "b", "d"), ("a", "b", "f")]
Source code in libs/checkpoint/langgraph/store/base/__init__.py
alist_namespaces(*, prefix: Optional[NameSpacePath] = None, suffix: Optional[NameSpacePath] = None, max_depth: Optional[int] = None, limit: int = 100, offset: int = 0) -> list[tuple[str, ...]]
async
¶
List and filter namespaces in the store asynchronously.
Used to explore the organization of data, find specific collections, or navigate the namespace hierarchy.
Parameters:
-
prefix
(
, default:Optional [Tuple [str , ...]]None
) –Filter namespaces that start with this path.
-
suffix
(
, default:Optional [Tuple [str , ...]]None
) –Filter namespaces that end with this path.
-
max_depth
(
, default:Optional [int ]None
) –Return namespaces up to this depth in the hierarchy. Namespaces deeper than this level will be truncated to this depth.
-
limit
(
, default:int 100
) –Maximum number of namespaces to return (default 100).
-
offset
(
, default:int 0
) –Number of namespaces to skip for pagination (default 0).
Returns:
-
–list [tuple [str , ...]]List[Tuple[str, ...]]: A list of namespace tuples that match the criteria.
-
–list [tuple [str , ...]]Each tuple represents a full namespace path up to
max_depth
.
Examples:
Setting max_depth=3. Given the namespaces:
# ("a", "b", "c")
# ("a", "b", "d", "e")
# ("a", "b", "d", "i")
# ("a", "b", "f")
# ("a", "c", "f")
await store.alist_namespaces(prefix=("a", "b"), max_depth=3)
# [("a", "b", "c"), ("a", "b", "d"), ("a", "b", "f")]
Source code in libs/checkpoint/langgraph/store/base/__init__.py
from_conn_string(conn_string: str) -> AsyncIterator[AsyncPostgresStore]
async
classmethod
¶
Create a new AsyncPostgresStore instance from a connection string.
Parameters:
-
conn_string
(
) –str The Postgres connection info string.
Returns:
-
AsyncPostgresStore
(
) –AsyncIterator [AsyncPostgresStore ]A new AsyncPostgresStore instance.
Source code in libs/checkpoint-postgres/langgraph/store/postgres/aio.py
setup() -> None
async
¶
Set up the store database asynchronously.
This method creates the necessary tables in the Postgres database if they don't already exist and runs database migrations. It MUST be called directly by the user the first time the store is used.
Source code in libs/checkpoint-postgres/langgraph/store/postgres/aio.py
PostgresStore
¶
Bases:
,
Source code in libs/checkpoint-postgres/langgraph/store/postgres/base.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
|
get(namespace: tuple[str, ...], key: str) -> Optional[Item]
¶
Retrieve a single item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
Returns:
-
–Optional [Item ]The retrieved item or None if not found.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
search(namespace_prefix: tuple[str, ...], /, *, filter: Optional[dict[str, Any]] = None, limit: int = 10, offset: int = 0) -> list[Item]
¶
Search for items within a namespace prefix.
Parameters:
-
namespace_prefix
(
) –tuple [str , ...]Hierarchical path prefix to search within.
-
filter
(
, default:Optional [dict [str ,Any ]]None
) –Key-value pairs to filter results.
-
limit
(
, default:int 10
) –Maximum number of items to return.
-
offset
(
, default:int 0
) –Number of items to skip before returning results.
Returns:
-
–list [Item ]List of items matching the search criteria.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
put(namespace: tuple[str, ...], key: str, value: dict[str, Any]) -> None
¶
Store or update an item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
-
value
(
) –dict [str ,Any ]Dictionary containing the item's data.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
delete(namespace: tuple[str, ...], key: str) -> None
¶
Delete an item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
list_namespaces(*, prefix: Optional[NameSpacePath] = None, suffix: Optional[NameSpacePath] = None, max_depth: Optional[int] = None, limit: int = 100, offset: int = 0) -> list[tuple[str, ...]]
¶
List and filter namespaces in the store.
Used to explore the organization of data, find specific collections, or navigate the namespace hierarchy.
Parameters:
-
prefix
(
, default:Optional [Tuple [str , ...]]None
) –Filter namespaces that start with this path.
-
suffix
(
, default:Optional [Tuple [str , ...]]None
) –Filter namespaces that end with this path.
-
max_depth
(
, default:Optional [int ]None
) –Return namespaces up to this depth in the hierarchy. Namespaces deeper than this level will be truncated to this depth.
-
limit
(
, default:int 100
) –Maximum number of namespaces to return (default 100).
-
offset
(
, default:int 0
) –Number of namespaces to skip for pagination (default 0).
Returns:
-
–list [tuple [str , ...]]List[Tuple[str, ...]]: A list of namespace tuples that match the criteria.
-
–list [tuple [str , ...]]Each tuple represents a full namespace path up to
max_depth
.
Examples:
Setting max_depth=3. Given the namespaces:
# ("a", "b", "c")
# ("a", "b", "d", "e")
# ("a", "b", "d", "i")
# ("a", "b", "f")
# ("a", "c", "f")
store.list_namespaces(prefix=("a", "b"), max_depth=3)
# [("a", "b", "c"), ("a", "b", "d"), ("a", "b", "f")]
Source code in libs/checkpoint/langgraph/store/base/__init__.py
aget(namespace: tuple[str, ...], key: str) -> Optional[Item]
async
¶
Asynchronously retrieve a single item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
Returns:
-
–Optional [Item ]The retrieved item or None if not found.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
asearch(namespace_prefix: tuple[str, ...], /, *, filter: Optional[dict[str, Any]] = None, limit: int = 10, offset: int = 0) -> list[Item]
async
¶
Asynchronously search for items within a namespace prefix.
Parameters:
-
namespace_prefix
(
) –tuple [str , ...]Hierarchical path prefix to search within.
-
filter
(
, default:Optional [dict [str ,Any ]]None
) –Key-value pairs to filter results.
-
limit
(
, default:int 10
) –Maximum number of items to return.
-
offset
(
, default:int 0
) –Number of items to skip before returning results.
Returns:
-
–list [Item ]List of items matching the search criteria.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
aput(namespace: tuple[str, ...], key: str, value: dict[str, Any]) -> None
async
¶
Asynchronously store or update an item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
-
value
(
) –dict [str ,Any ]Dictionary containing the item's data.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
adelete(namespace: tuple[str, ...], key: str) -> None
async
¶
Asynchronously delete an item.
Parameters:
-
namespace
(
) –tuple [str , ...]Hierarchical path for the item.
-
key
(
) –str Unique identifier within the namespace.
Source code in libs/checkpoint/langgraph/store/base/__init__.py
alist_namespaces(*, prefix: Optional[NameSpacePath] = None, suffix: Optional[NameSpacePath] = None, max_depth: Optional[int] = None, limit: int = 100, offset: int = 0) -> list[tuple[str, ...]]
async
¶
List and filter namespaces in the store asynchronously.
Used to explore the organization of data, find specific collections, or navigate the namespace hierarchy.
Parameters:
-
prefix
(
, default:Optional [Tuple [str , ...]]None
) –Filter namespaces that start with this path.
-
suffix
(
, default:Optional [Tuple [str , ...]]None
) –Filter namespaces that end with this path.
-
max_depth
(
, default:Optional [int ]None
) –Return namespaces up to this depth in the hierarchy. Namespaces deeper than this level will be truncated to this depth.
-
limit
(
, default:int 100
) –Maximum number of namespaces to return (default 100).
-
offset
(
, default:int 0
) –Number of namespaces to skip for pagination (default 0).
Returns:
-
–list [tuple [str , ...]]List[Tuple[str, ...]]: A list of namespace tuples that match the criteria.
-
–list [tuple [str , ...]]Each tuple represents a full namespace path up to
max_depth
.
Examples:
Setting max_depth=3. Given the namespaces:
# ("a", "b", "c")
# ("a", "b", "d", "e")
# ("a", "b", "d", "i")
# ("a", "b", "f")
# ("a", "c", "f")
await store.alist_namespaces(prefix=("a", "b"), max_depth=3)
# [("a", "b", "c"), ("a", "b", "d"), ("a", "b", "f")]
Source code in libs/checkpoint/langgraph/store/base/__init__.py
from_conn_string(conn_string: str) -> Iterator[PostgresStore]
classmethod
¶
Create a new BasePostgresStore instance from a connection string.
Parameters:
-
conn_string
(
) –str The Postgres connection info string.
Returns:
-
BasePostgresStore
(
) –Iterator [PostgresStore ]A new BasePostgresStore instance.
Source code in libs/checkpoint-postgres/langgraph/store/postgres/base.py
setup() -> None
¶
Set up the store database.
This method creates the necessary tables in the Postgres database if they don't already exist and runs database migrations. It MUST be called directly by the user the first time the store is used.