Skip to main content

alloydb_client.py

Source: sunholo/database/alloydb_client.py

Classes

AlloyDBClient

A class to manage interactions with an AlloyDB instance.

Example Usage:

client = AlloyDBClient(
project_id="your-project-id",
region="your-region",
cluster_name="your-cluster-name",
instance_name="your-instance-name",
user="your-db-user",
password="your-db-password"
)

# Create a database
client.execute_sql("CREATE DATABASE my_database")

# Execute other SQL statements
client.execute_sql("CREATE TABLE my_table (id INT, name VARCHAR(50))")
  • init(self, config: sunholo.utils.config_class.ConfigManager = None, project_id: str = None, region: str = None, cluster_name: str = None, instance_name: str = None, user: str = None, password: str = None, db='postgres')
    • Initializes the AlloyDB client.
  • project_id (str): GCP project ID where the AlloyDB instance resides.
  • region (str): The region where the AlloyDB instance is located.
  • cluster_name (str): The name of the AlloyDB cluster.
  • instance_name (str): The name of the AlloyDB instance.
  • user (str): If user is None will use the default service email
  • db_name (str): The name of the database.
  • _and_or_ilike(sources, search_type='OR', operator='ILIKE')

    • No docstring available.
  • _build_instance_uri(self, project_id, region, cluster_name, instance_name)

    • No docstring available.
  • _create_engine(self)

    • No docstring available.
  • _create_engine_from_pg8000(self, user, password, db)

    • No docstring available.
  • _execute_sql_async_langchain(self, sql_statement)

    • No docstring available.
  • _execute_sql_async_pg8000(self, sql_statement)

    • Executes a given SQL statement asynchronously with error handling.
  • _execute_sql_langchain(self, sql_statement)

    • No docstring available.
  • _execute_sql_pg8000(self, sql_statement)

    • Executes a given SQL statement with error handling.
  • sql_statement (str): The SQL statement to execute.
  • Returns: The result of the execution, if any.
  • _get_document_from_docstore(self, source: str, vector_name: str)

    • No docstring available.
  • _get_document_via_docid(self, source: str, vector_name: str, doc_id: str)

    • No docstring available.
  • _get_embedder(self)

    • No docstring available.
  • _get_sources_from_docstore(self, sources, vector_name, search_type='OR')

    • Helper function to build the SQL query for fetching sources.
  • _list_sources_from_docstore(self, sources, vector_name, search_type='OR')

    • Helper function to build the SQL query for listing sources.
  • _similarity_search(self, query, source_filter: str = '', free_filter: str = None, vector_name: str = None)

    • No docstring available.
  • asimilarity_search(self, query: str, source_filter: str = '', free_filter: str = None, k: int = 5, vector_name: str = None)

    • No docstring available.
  • create_database(self, database_name)

    • No docstring available.
  • create_docstore_table(self, vector_name: str, users)

    • No docstring available.
  • create_index(self, vectorstore=None)

    • No docstring available.
  • create_schema(self, schema_name='public')

    • No docstring available.
  • create_tables(self, vector_name, users)

    • No docstring available.
  • create_vectorstore_table(self, vector_name: str, users)

    • No docstring available.
  • delete_sources_from_alloydb(self, sources, vector_name)

    • Deletes from both vectorstore and docstore
  • execute_sql(self, sql_statement)

    • No docstring available.
  • execute_sql_async(self, sql_statement)

    • No docstring available.
  • fetch_owners(self)

    • No docstring available.
  • get_document_from_docstore(self, source: str, vector_name)

    • No docstring available.
  • get_document_from_docstore_async(self, source: str, vector_name: str)

    • No docstring available.
  • get_sources_from_docstore(self, sources, vector_name, search_type='OR', just_source_name=False)

    • Fetches sources from the docstore.
  • get_sources_from_docstore_async(self, sources, vector_name, search_type='OR', just_source_name=False)

    • Fetches sources from the docstore asynchronously.
  • get_vectorstore(self, vector_name: str = None)

    • No docstring available.
  • grant_schema_permissions(self, schema_name, users)

    • No docstring available.
  • grant_table_permissions(self, table_name, users)

    • No docstring available.
  • refresh_index(self, vectorstore=None)

    • No docstring available.
  • similarity_search(self, query: str, source_filter: str = '', free_filter: str = None, k: int = 5, vector_name: str = None)

    • No docstring available.
Sunholo Multivac

Get in touch to see if we can help with your GenAI project.

Contact us

Other Links

Sunholo Multivac - GenAIOps

Copyright ©

Holosun ApS 2024