Exceptions API
The Manticore CockroachDB client defines custom exceptions to handle specific error cases.
Class Documentation
TableNotInitializedError
Bases: DatabaseError
Raised when trying to use a table that has not been initialized.
Source code in manticore_cockroachdb/crud/exceptions.py
Functions
__init__(table_name)
Initialize table not initialized error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table_name
|
str
|
Name of the table that is not initialized |
required |
Source code in manticore_cockroachdb/crud/exceptions.py
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']}")