Example integration showing how to use the multi-database adapter system.
This namespace demonstrates how to:
Example integration showing how to use the multi-database adapter system. This namespace demonstrates how to: - Load environment-specific configurations - Initialize database adapters based on active configurations - Use the initialized adapters for database operations - Handle multiple active databases simultaneously
(current-state)Get current application state - useful for debugging.
Get current application state - useful for debugging.
(example-basic-usage)Demonstrate basic usage of the multi-database system.
Demonstrate basic usage of the multi-database system.
(example-environment-switching)Demonstrate switching between different environment configurations.
Demonstrate switching between different environment configurations.
(execute-query adapter-key query-map)Execute a query on a specific database adapter.
Args: adapter-key - Keyword identifying the adapter query-map - HoneySQL query map
Returns: Query results or throws exception
Execute a query on a specific database adapter. Args: adapter-key - Keyword identifying the adapter query-map - HoneySQL query map Returns: Query results or throws exception
(get-database adapter-key)Get a specific database adapter by key.
Args: adapter-key - Keyword identifying the adapter (e.g., :wagoe/sqlite)
Returns: {:adapter adapter-config :pool connection-pool} or nil
Get a specific database adapter by key.
Args:
adapter-key - Keyword identifying the adapter (e.g., :wagoe/sqlite)
Returns: {:adapter adapter-config :pool connection-pool} or nil(get-primary-database)Get the primary database (first active adapter).
Useful when you have a single active database or want a default.
Get the primary database (first active adapter). Useful when you have a single active database or want a default.
(initialize-databases!)(initialize-databases! environment)Initialize all active databases based on the current environment configuration.
This function:
Returns: map of {:adapter-key {:adapter adapter :pool pool}}
Initialize all active databases based on the current environment configuration.
This function:
1. Loads the environment-specific config.edn
2. Identifies active database adapters
3. Loads required JDBC drivers based on active databases
4. Creates connection pools for each active adapter
5. Stores the initialized adapters in application state
Returns: map of {:adapter-key {:adapter adapter :pool pool}}(list-active-databases)List all currently active database adapters.
Returns: sequence of [adapter-key {:adapter ... :pool ...}]
List all currently active database adapters.
Returns: sequence of [adapter-key {:adapter ... :pool ...}](reset-application-state!)Reset application state - useful for development and testing.
Reset application state - useful for development and testing.
(shutdown-databases!)Safely shutdown all active database connections.
Safely shutdown all active database connections.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |