一覧へ戻る
brettatoms/zodiac-sql(新しいタブで開きます)
主要言語: Clojure
A Zodiac extension for connecting to a SQL database
- star 数
- 4
- watcher 数
- 2
- fork 数
- 0
- issue 数
- 0
- 最終更新
- 2026/07/24
主要言語: Clojure
A Zodiac extension for connecting to a SQL database
An extension for Zodiac to help with connecting to a SQL database with next.jdbc and execute queries with HoneySQL.
For an example of how to use this extension see examples/hello-world.
(ns myapp (:require [zodiac.core :as z] [zodiac.ext.sql :as z.sql])) (defn handler [{:keys [::z/context]}] (let [{:keys [::z.sql/db]} context {:keys [message]} (z.sql/execute-one! db {:select [["hello world" :message]]})] [:html [:head [:meta {:name "viewport" :content "width=device-width, initial-scale=1"}]] [:body message]])) (defn routes [] ["/" {:get #'handler}]) (let [sql-ext (z.sql/init {:spec {:jdbcUrl "jdbc:sqlite:hello-world.db"}})] (z/start {:extensions [sql-ext] :routes #'routes})
The zodiac.ext.sql/init accepts the following options:
:spec: The datasource and connection options map. For more information see Datasources and Connections in the next.jdbc docs:jdbc-options: The options for building generating SQL and results set. For more information see Generating SQL and Generating Rows and Result Sets in the next.jdbc docs.:context-key: The key in the zodiac request context that will hold the database connection. Defaults to :zodiac.ext.sql/db.