One DBAdapter implementation, over a per-engine spec.
There used to be four, and they were copies: each query.clj was the same
sixty lines turning on two decisions, and each core.clj was thirty lines of
delegation. A fix landed in one and not its neighbours — that is how H2 came
to carry a table-exists? workaround while SQLite and MySQL reported every
table as absent (BOU-430).
A spec names what the port says may differ between engines, and nothing else:
:label for log lines — "MySQL" :dialect what callers dispatch on; nil means PostgreSQL :driver JDBC driver class name :jdbc-url (fn [db-config] -> String) :pool HikariCP defaults :session-statements (fn [db-config] -> seq of JDBC param vectors) :booleans :native or :int :string-match :like or :ilike :table-exists? (fn [datasource table-name] -> boolean) :table-info (fn [datasource table-name] -> vector of column maps)
One `DBAdapter` implementation, over a per-engine spec. There used to be four, and they were copies: each `query.clj` was the same sixty lines turning on two decisions, and each `core.clj` was thirty lines of delegation. A fix landed in one and not its neighbours — that is how H2 came to carry a `table-exists?` workaround while SQLite and MySQL reported every table as absent (BOU-430). A spec names what the port says may differ between engines, and nothing else: :label for log lines — "MySQL" :dialect what callers dispatch on; nil means PostgreSQL :driver JDBC driver class name :jdbc-url (fn [db-config] -> String) :pool HikariCP defaults :session-statements (fn [db-config] -> seq of JDBC param vectors) :booleans :native or :int :string-match :like or :ilike :table-exists? (fn [datasource table-name] -> boolean) :table-info (fn [datasource table-name] -> vector of column maps)
Common connection pool management utilities.
Common connection pool management utilities.
Common database operations - main coordination module.
This namespace serves as the main coordinator for common database functionality, bringing together specialized modules for different aspects of database operations that work across all adapter types.
The common functionality has been refactored into specialized namespaces:
Pure query building functions are now in wagoe.platform.core.database.query
This modular structure provides:
Common database operations - main coordination module. This namespace serves as the main coordinator for common database functionality, bringing together specialized modules for different aspects of database operations that work across all adapter types. The common functionality has been refactored into specialized namespaces: - common.connection: Connection pool management with HikariCP - common.execution: Query execution with logging and error handling - common.schema: Schema introspection and DDL execution - common.utils: Database information and convenience functions - common.core: Main coordination module (this namespace) Pure query building functions are now in wagoe.platform.core.database.query This modular structure provides: - Better organization with focused responsibilities - Easier maintenance and testing - Consistent patterns across all database adapters - Clear separation of concerns
Query execution with I/O, logging, and error handling.
This is part of the imperative shell - it performs database I/O, manages transactions, and handles side effects like logging.
Query execution with I/O, logging, and error handling. This is part of the imperative shell - it performs database I/O, manages transactions, and handles side effects like logging.
Table introspection for every adapter.
PostgreSQL, MySQL and H2 all read information_schema and differ only in
which schema predicate identifies "this database", which HoneySQL dialect
formats the query, and whether the table name may be folded to lower case.
SQLite has no information_schema and reads sqlite_master and
PRAGMA table_info instead.
Both forms return the same column maps — :name (lower case), :type,
:not-null, :default, :primary-key — which is what the port promises
and what the four separate copies did not consistently deliver.
Table introspection for every adapter. PostgreSQL, MySQL and H2 all read `information_schema` and differ only in which schema predicate identifies "this database", which HoneySQL dialect formats the query, and whether the table name may be folded to lower case. SQLite has no `information_schema` and reads `sqlite_master` and `PRAGMA table_info` instead. Both forms return the same column maps — `:name` (lower case), `:type`, `:not-null`, `:default`, `:primary-key` — which is what the port promises and what the four separate copies did not consistently deliver.
Common schema management and DDL utilities.
Common schema management and DDL utilities.
Common database utilities and information functions.
Common database utilities and information functions.
Configuration-driven database adapter management.
This namespace provides functionality to read database configuration from config.edn and only load adapters that are marked as :active. This allows for optimized deployments where only required database drivers are loaded.
Key Features:
Usage: (require '[wagoe.platform.shell.adapters.database.config :as db-config])
(db-config/get-active-adapters "dev") ; Get active adapters for dev env (db-config/adapter-active? :postgresql) ; Check if adapter is active
Configuration-driven database adapter management. This namespace provides functionality to read database configuration from config.edn and only load adapters that are marked as :active. This allows for optimized deployments where only required database drivers are loaded. Key Features: - Configuration-driven adapter loading - Environment-specific database configs - Graceful handling of inactive adapters - JDBC driver optimization (only load needed drivers) Usage: (require '[wagoe.platform.shell.adapters.database.config :as db-config]) (db-config/get-active-adapters "dev") ; Get active adapters for dev env (db-config/adapter-active? :postgresql) ; Check if adapter is active
Factory functions for database adapter creation and configuration.
This namespace provides convenient factory functions for creating database adapters, data sources, and database contexts. It supports multiple database types (SQLite, PostgreSQL, MySQL, H2) through a unified configuration interface.
Key Features:
Usage: (require '[wagoe.platform.shell.adapters.database.factory :as dbf])
(def ctx (dbf/db-context {:adapter :sqlite :database-path "./app.db"})) (db/execute-query! ctx {:select [:*] :from [:users]})
Factory functions for database adapter creation and configuration.
This namespace provides convenient factory functions for creating database
adapters, data sources, and database contexts. It supports multiple database
types (SQLite, PostgreSQL, MySQL, H2) through a unified configuration interface.
Key Features:
- Database adapter creation from configuration
- Connection pool and datasource management
- Database context creation with adapter + datasource
- Resource management with automatic cleanup
- Configuration validation and error handling
Usage:
(require '[wagoe.platform.shell.adapters.database.factory :as dbf])
(def ctx (dbf/db-context {:adapter :sqlite :database-path "./app.db"}))
(db/execute-query! ctx {:select [:*] :from [:users]})H2 connection settings and JDBC URL.
H2 connection settings and JDBC URL.
H2 adapter.
Runs in PostgreSQL compatibility mode with DATABASE_TO_LOWER, so identifiers behave like PostgreSQL's; native booleans; ANSI SQL.
H2 adapter. Runs in PostgreSQL compatibility mode with DATABASE_TO_LOWER, so identifiers behave like PostgreSQL's; native booleans; ANSI SQL.
MySQL connection settings and JDBC URL.
MySQL connection settings and JDBC URL.
MySQL adapter.
LIKE (case-insensitive by MySQL's default collation), booleans as TINYINT(1), and a table name that is not folded — on a case-sensitive filesystem MySQL table names are case-sensitive.
MySQL adapter. LIKE (case-insensitive by MySQL's default collation), booleans as TINYINT(1), and a table name that is not folded — on a case-sensitive filesystem MySQL table names are case-sensitive.
PostgreSQL connection settings and JDBC URL.
PostgreSQL connection settings and JDBC URL.
PostgreSQL adapter.
Case-insensitive matching with ILIKE, native booleans, and session settings carried on the JDBC URL rather than applied per connection — see postgresql.connection.
PostgreSQL adapter. Case-insensitive matching with ILIKE, native booleans, and session settings carried on the JDBC URL rather than applied per connection — see postgresql.connection.
SQLite connection settings and JDBC URL.
SQLite connection settings and JDBC URL.
SQLite adapter.
Booleans as integers, no information_schema — introspection reads sqlite_master and PRAGMA table_info — and a set of PRAGMAs applied per connection, see sqlite.connection.
SQLite adapter. Booleans as integers, no information_schema — introspection reads sqlite_master and PRAGMA table_info — and a set of PRAGMAs applied per connection, see sqlite.connection.
Dynamic JDBC driver loading based on active database configurations.
This namespace provides configuration-driven driver loading that eliminates the need to coordinate between configuration files and command-line aliases. Drivers are loaded dynamically based on which databases are marked as :active in the configuration files.
Key Features:
Usage: (require '[wagoe.platform.shell.adapters.database.utils.driver-loader :as dl])
;; Load drivers for active databases in current environment (dl/load-required-drivers!)
;; Load drivers for specific environment (dl/load-drivers-for-environment! "dev")
Dynamic JDBC driver loading based on active database configurations. This namespace provides configuration-driven driver loading that eliminates the need to coordinate between configuration files and command-line aliases. Drivers are loaded dynamically based on which databases are marked as :active in the configuration files. Key Features: - Single source of truth: configuration files control everything - Clear error messages when drivers are missing - Automatic driver detection from active databases - No command-line alias coordination required Usage: (require '[wagoe.platform.shell.adapters.database.utils.driver-loader :as dl]) ;; Load drivers for active databases in current environment (dl/load-required-drivers!) ;; Load drivers for specific environment (dl/load-drivers-for-environment! "dev")
Schema-to-DDL generation utilities for database adapters.
This namespace provides utilities for generating database DDL statements from Malli schema definitions. It handles:
Key Features:
Usage: (require '[wagoe.platform.shell.adapters.database.utils.schema :as schema])
(schema/generate-table-ddl ctx "users" some-malli-schema) (schema/initialize-tables-from-schemas! ctx schema-map)
Schema-to-DDL generation utilities for database adapters. This namespace provides utilities for generating database DDL statements from Malli schema definitions. It handles: - Column type mapping based on database dialect - Table creation with constraints - Index generation from schema analysis - Cross-database compatibility Key Features: - Uses Malli schemas as canonical source of truth - Database-specific column type mapping - Foreign key and unique constraint generation - Automatic index creation based on field patterns Usage: (require '[wagoe.platform.shell.adapters.database.utils.schema :as schema]) (schema/generate-table-ddl ctx "users" some-malli-schema) (schema/initialize-tables-from-schemas! ctx schema-map)
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 |