Skip to content

ruroru/boa-sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Boa SQL

A library for a better work with SQL

Installation

Add to your dependency list:

[org.clojars.jj/boa-sql "1.0.0-SNAPSHOT"]

Usage

Create a query file in your resources directory with variables marked with :variable

(require [jj.sql.boa :as boa])

(def query (boa/execute (boa/->NextJdbcAdapter) "query-in-resource.sql"))

;; Execute with context
(query data-source {:user-id 42})

Single value

;; Query: SELECT * FROM users WHERE user_id = :user-id;
(query data-source {:user-id 123})
;; Produces: SELECT * FROM users WHERE user_id = ?;
;; Parameters: [123]

Tuple

;; Query: INSERT INTO numbers (first, second, third) VALUES :numbers
(query data-source {:numbers [1 2 3]})
;; Produces: WHERE id IN (?,?,?)
;; Parameters: [1 2 3]

Sequence of tuples

;; Query: INSERT INTO users (name, age) VALUES :users
(query data-source {:users [["Alice" 30] ["Bob" 25]]})
;; Produces: INSERT INTO users (name, age) VALUES (?,?),(?,?)
;; Parameters: ["Alice" 30 "Bob" 25]

Tested on

databse
mariadb
mysql
postgresql
h2
derby
sqlite

License

Copyright © 2025 ruroru

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published