💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Move create schema calls into their own transaction #831
davidmezzetti0354e2bef390
diff --git a/src/python/txtai/ann/pgvector.py b/src/python/txtai/ann/pgvector.pyindex a94ff6e0..24677718 100644--- a/src/python/txtai/ann/pgvector.py+++ b/src/python/txtai/ann/pgvector.py@@ -104,7 +104,9 @@ class PGVector(ANN):# Set default schema, if necessaryschema = self.setting("schema")if schema:- self.sqldialect(CreateSchema(schema, if_not_exists=True))+ with self.engine.begin():+ self.sqldialect(CreateSchema(schema, if_not_exists=True))+self.sqldialect(text("SET search_path TO :schema,public"), {"schema": schema})# Table namediff --git a/src/python/txtai/database/client.py b/src/python/txtai/database/client.pyindex da671510..25efe7ad 100644--- a/src/python/txtai/database/client.py+++ b/src/python/txtai/database/client.py@@ -139,7 +139,9 @@ class Client(RDBMS):# Set default schema, if necessaryschema = self.config.get("schema")if schema:- self.sqldialect(database, CreateSchema(schema, if_not_exists=True))+ with self.engine.begin():+ self.sqldialect(database, CreateSchema(schema, if_not_exists=True))+self.sqldialect(database, textsql("SET search_path TO :schema"), {"schema": schema})return databasediff --git a/src/python/txtai/graph/rdbms.py b/src/python/txtai/graph/rdbms.pyindex 4417afae..564575aa 100644--- a/src/python/txtai/graph/rdbms.py+++ b/src/python/txtai/graph/rdbms.py@@ -95,7 +95,7 @@ class RDBMS(NetworkX):if schema:# Check that schema existsengine = create_engine(url)- with engine.connect() as connection:+ with engine.begin() as connection:connection.execute(CreateSchema(schema, if_not_exists=True) if "postgresql" in url else text("SELECT 1"))# Set default schemadiff --git a/src/python/txtai/scoring/pgtext.py b/src/python/txtai/scoring/pgtext.pyindex 07f82778..4569151a 100644--- a/src/python/txtai/scoring/pgtext.py+++ b/src/python/txtai/scoring/pgtext.py@@ -131,7 +131,9 @@ class PGText(Scoring):# Set default schema, if necessaryschema = self.config.get("schema")if schema:- self.sqldialect(CreateSchema(schema, if_not_exists=True))+ with self.engine.begin():+ self.sqldialect(CreateSchema(schema, if_not_exists=True))+self.sqldialect(text("SET search_path TO :schema"), {"schema": schema})# Table name