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, project_id: str, region: str, cluster_name: str, instance_name: str, user: str, password=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): The database user name.
- password (str): The database user's password.
- 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, inst_uri, user, password, db)
- No docstring available.
-
create_database(self, database_name)
- No docstring available.
-
create_docstore_table(self, vector_name: str, users)
- 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)
- Executes a given SQL statement with error handling.
- sql_statement (str): The SQL statement to execute.
- Returns: The result of the execution, if any.
-
fetch_owners(self)
- No docstring available.
-
grant_schema_permissions(self, schema_name, users)
- No docstring available.
-
grant_table_permissions(self, table_name, users)
- No docstring available.