llama-index-vector-stores-postgres 0.2.6__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llama-index-vector-stores-postgres
3
- Version: 0.2.6
3
+ Version: 0.3.1
4
4
  Summary: llama-index vector_stores postgres integration
5
5
  License: MIT
6
6
  Author: Your Name
7
7
  Author-email: you@example.com
8
- Requires-Python: >=3.8.1,<4.0
8
+ Requires-Python: >=3.9,<4.0
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Programming Language :: Python :: 3.9
@@ -13,7 +13,7 @@ Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Requires-Dist: asyncpg (>=0.29.0,<0.30.0)
16
- Requires-Dist: llama-index-core (>=0.11.0,<0.12.0)
16
+ Requires-Dist: llama-index-core (>=0.12.0,<0.13.0)
17
17
  Requires-Dist: pgvector (>=0.2.4,<0.3.0)
18
18
  Requires-Dist: psycopg2-binary (>=2.9.9,<3.0.0)
19
19
  Requires-Dist: sqlalchemy[asyncio] (>=1.4.49,<2.1)
@@ -341,7 +341,11 @@ class PGVectorStore(BasePydanticVectorStore):
341
341
  )
342
342
  self._async_session = sessionmaker(self._async_engine, class_=AsyncSession) # type: ignore
343
343
 
344
- def _create_schema_if_not_exists(self) -> None:
344
+ def _create_schema_if_not_exists(self) -> bool:
345
+ """
346
+ Create the schema if it does not exist.
347
+ Returns True if the schema was created, False if it already existed.
348
+ """
345
349
  if not re.match(r"^[A-Za-z_][A-Za-z0-9_]*$", self.schema_name):
346
350
  raise ValueError(f"Invalid schema_name: {self.schema_name}")
347
351
  with self._session() as session, session.begin():
@@ -352,7 +356,8 @@ class PGVectorStore(BasePydanticVectorStore):
352
356
  result = session.execute(check_schema_statement).fetchone()
353
357
 
354
358
  # If the schema does not exist, then create it
355
- if not result:
359
+ schema_doesnt_exist = result is None
360
+ if schema_doesnt_exist:
356
361
  create_schema_statement = sqlalchemy.text(
357
362
  # DDL won't tolerate quoted string literal here for schema_name,
358
363
  # so use a format string to embed the schema_name directly, instead of a param.
@@ -361,6 +366,7 @@ class PGVectorStore(BasePydanticVectorStore):
361
366
  session.execute(create_schema_statement)
362
367
 
363
368
  session.commit()
369
+ return schema_doesnt_exist
364
370
 
365
371
  def _create_tables_if_not_exists(self) -> None:
366
372
  with self._session() as session, session.begin():
@@ -402,8 +408,11 @@ class PGVectorStore(BasePydanticVectorStore):
402
408
  if not self._is_initialized:
403
409
  self._connect()
404
410
  if self.perform_setup:
411
+ schema_created = self._create_schema_if_not_exists()
412
+ if not schema_created:
413
+ self._is_initialized = True
414
+ return # Skip table creation if schema already existed
405
415
  self._create_extension()
406
- self._create_schema_if_not_exists()
407
416
  self._create_tables_if_not_exists()
408
417
  if self.hnsw_kwargs is not None:
409
418
  self._create_hnsw_index()
@@ -27,14 +27,14 @@ exclude = ["**/BUILD"]
27
27
  license = "MIT"
28
28
  name = "llama-index-vector-stores-postgres"
29
29
  readme = "README.md"
30
- version = "0.2.6"
30
+ version = "0.3.1"
31
31
 
32
32
  [tool.poetry.dependencies]
33
- python = ">=3.8.1,<4.0"
33
+ python = ">=3.9,<4.0"
34
34
  pgvector = "^0.2.4"
35
35
  psycopg2-binary = "^2.9.9"
36
36
  asyncpg = "^0.29.0"
37
- llama-index-core = "^0.11.0"
37
+ llama-index-core = "^0.12.0"
38
38
 
39
39
  [tool.poetry.dependencies.sqlalchemy]
40
40
  extras = ["asyncio"]