Skip to content

Exceptions API

The Manticore CockroachDB client defines custom exceptions to handle specific error cases.

Class Documentation

TableNotInitializedError

Bases: Exception

Raised when trying to use a table that has not been initialized.

Source code in manticore_cockroachdb/crud/exceptions.py
class TableNotInitializedError(Exception):
    """Raised when trying to use a table that has not been initialized."""
    pass 

Usage Examples

from manticore_cockroachdb import Database, Table
from manticore_cockroachdb.crud.exceptions import TableNotInitializedError

# Connect to database
db = Database(database="example_db")

# Create a Table instance without initializing
users = Table("users")

try:
    # Attempt to use the table before initializing
    user = users.create({"name": "John Doe", "email": "john@example.com"})
except TableNotInitializedError as e:
    print(f"Error: {e}")
    # Initialize the table
    users.db = db

# Now the table can be used
user = users.create({"name": "John Doe", "email": "john@example.com"})
print(f"Created user with ID: {user['id']}")