Database class represents a jasonisnthappy database instance.
Opening a database
open
Opens a database at the specified path.str
required
Path to the database file
Database
Database instance
open_with_options
Opens a database with custom options.str
required
Path to the database file
CDatabaseOptions
required
Custom database configuration options
Database
Database instance
default_database_options
Returns the default database options.CDatabaseOptions
Default database configuration
Database management
close
Closes the database and frees associated resources.Context manager support
Use thewith statement for automatic resource cleanup.
Example:
begin_transaction
Begins a new transaction.Transaction
Transaction instance
get_collection
Gets a collection reference for non-transactional operations.str
required
Name of the collection
Collection
Collection handle
Configuration
set_transaction_config
Sets the transaction retry configuration.CTransactionConfig
required
Transaction configuration with retry settings
get_transaction_config
Gets the current transaction configuration.CTransactionConfig
Current transaction configuration
set_auto_checkpoint_threshold
Sets the auto-checkpoint threshold in WAL frames.int
required
Number of WAL frames before automatic checkpoint
Database information
get_path
Gets the database file path.str
Database file path
is_read_only
Checks if the database is read-only.bool
True if the database is read-only
list_collections
Lists all collections in the database.List[str]
List of collection names
collection_stats
Gets statistics for a collection.str
required
Name of the collection
Dict[str, Any]
Collection statistics
database_info
Gets database information.Dict[str, Any]
Database information including path, size, collections, etc.
max_bulk_operations
Returns the maximum number of bulk operations allowed.int
Maximum bulk operations limit
max_document_size
Returns the maximum document size in bytes.int
Maximum document size in bytes
max_request_body_size
Returns the maximum HTTP request body size in bytes.int
Maximum request body size in bytes
Index management
create_index
Creates a single-field index.str
required
Name of the collection
str
required
Name for the index
str
required
Field to index
bool
default:"False"
Whether the index should enforce uniqueness
create_compound_index
Creates a compound index on multiple fields.str
required
Name of the collection
str
required
Name for the index
List[str]
required
Fields to include in the compound index
bool
default:"False"
Whether the index should enforce uniqueness
create_text_index
Creates a full-text search index.str
required
Name of the collection
str
required
Name for the index
str
required
Text field to index
drop_index
Drops an index from a collection.str
required
Name of the collection
str
required
Name of the index to drop
list_indexes
Lists all indexes for a collection.str
required
Name of the collection
List[Dict[str, Any]]
List of index metadata
Schema validation
set_schema
Sets a JSON schema for validation.str
required
Name of the collection
Dict[str, Any]
required
JSON schema for validation
get_schema
Gets the JSON schema for a collection.str
required
Name of the collection
Optional[Dict[str, Any]]
JSON schema, or None if no schema is set
remove_schema
Removes the JSON schema from a collection.str
required
Name of the collection
Maintenance
checkpoint
Performs a manual WAL checkpoint.backup
Creates a backup of the database.str
required
Destination path for the backup file
verify_backup
Verifies the integrity of a backup and returns backup info.str
required
Path to the backup file
Dict[str, Any]
Backup verification information
garbage_collect
Performs garbage collection and returns stats.Dict[str, Any]
Garbage collection statistics
metrics
Gets database metrics.Dict[str, Any]
Database metrics including reads, writes, cache hits, etc.
frame_count
Gets the number of WAL frames.int
Number of WAL frames
Web UI
start_web_ui
Starts the web UI server at the given address.str
required
Address to bind the web server to (e.g., “127.0.0.1:8080”)
WebServer
WebServer handle to control the server