> ## Documentation Index
> Fetch the complete documentation index at: https://anaconda.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Vector database

export const GCell = ({children, className}) => <div className={`grid-table-cell ${className || ""}`} role="cell">
    {children}
  </div>;

export const GTH = ({children, className}) => <div className={`grid-table-th ${className || ""}`} role="columnheader">
    {children}
  </div>;

export const GRow = ({children}) => <div className="grid-table-row" role="row">{children}</div>;

export const GBody = ({children}) => <div className="grid-table-body" role="rowgroup">{children}</div>;

export const GHead = ({children}) => <div className="grid-table-head" role="rowgroup">{children}</div>;

export const GTable = ({children, className, cols}) => <div className={`grid-table not-prose overflow-hidden rounded-2xl ${className || ""}`} style={{
  "--grid-table-cols": cols
}} role="table">
    {children}
  </div>;

The `.vector_db` accessor provides methods for managing a pgvector database instance:

<GTable cols="30% 30% 40%">
  <GHead>
    <GRow>
      <GTH>Method</GTH>
      <GTH>Return</GTH>
      <GTH>Description</GTH>
    </GRow>
  </GHead>

  <GBody>
    <GRow>
      <GCell>`.create()`</GCell>
      <GCell>`VectorDbServerResponse`</GCell>
      <GCell>Start the vector database and return connection details</GCell>
    </GRow>

    <GRow>
      <GCell>`.stop()`</GCell>
      <GCell>`VectorDbServerResponse`</GCell>
      <GCell>Stop the vector database (data preserved)</GCell>
    </GRow>

    <GRow>
      <GCell>`.delete()`</GCell>
      <GCell>`None`</GCell>
      <GCell>Permanently delete the vector database and all data</GCell>
    </GRow>

    <GRow>
      <GCell>`.get_tables()`</GCell>
      <GCell>`List[TableInfo]`</GCell>
      <GCell>List all tables in the vector database</GCell>
    </GRow>

    <GRow>
      <GCell>`.create_table(table, schema)`</GCell>
      <GCell>`None`</GCell>
      <GCell>Create a new table with the specified schema</GCell>
    </GRow>

    <GRow>
      <GCell>`.drop_table(table)`</GCell>
      <GCell>`None`</GCell>
      <GCell>Drop a table from the vector database</GCell>
    </GRow>
  </GBody>
</GTable>

<Note>
  Vector database functionality is only supported by the `ai-navigator` and `anaconda-desktop` backends. The `ai-catalyst` backend does not support vector database operations.
</Note>

### Example usage

```py theme={null}
from anaconda_ai import AnacondaAIClient

client = AnacondaAIClient(backend='anaconda-desktop')

# Start the vector database
db_info = client.vector_db.create()
print(f"Database running at: {db_info.uri}")

# Create a table for embeddings
schema = VectorDbTableSchema(columns=[
    VectorDbTableColumn(name="id", type="SERIAL", constraints=["PRIMARY KEY"]),
    VectorDbTableColumn(name="embedding", type="vector(384)")
])
client.vector_db.create_table("my_embeddings", schema)

# List tables
tables = client.vector_db.get_tables()
for table in tables:
    print(f"Table: {table.name}, Rows: {table.numRows}")

# Clean up
client.vector_db.drop_table("my_embeddings")
client.vector_db.stop()
```
