Questions tagged [korma]

Korma is a Clojure DSL wrapping common SQL database manipulation functions.

Korma is a domain specific language for Clojure that takes the pain out of working with your favorite RDBMS. Built for speed and designed for flexibility, Korma provides a simple and intuitive interface to your data that won't leave a bad taste in your mouth.

korma site

korma on github

70 questions
10
votes
2 answers

How do you make Korma output the SQL it would execute?

I'm trying to get Korma to output the SQL it would execute so I can debug a problem I'm having, but the docs are very terse on how to use the as-sql function. Can anyone give me an example of how to make Korma output the SQL for an INSERT query?
cap10morgan
  • 121
  • 1
  • 9
10
votes
2 answers

Code generation tool for SQL schema to Korma entities

Is there a tool to convert a SQL schema to Korma entities?
Timo Westkämper
  • 21,824
  • 5
  • 78
  • 111
8
votes
4 answers

Trouble connecting to postgresql DB on Heroku with Korma (Clojure)

I am parsing the postgresql uri in my config settings on Heroku. But I cannot seem to get it working. Any help would be greatly appreciated, I'm probably missing something straight forward. Here is the code used. (def dev-db-info {:db "dbname" …
conorwade
  • 115
  • 1
  • 5
6
votes
1 answer

Attempting to Create a User Login for Clojure / Korma / PostgreSQL site

I am completely stuck on where to start with getting a log-in area for a Clojure site I am building (for fun). I've looked at several resources, which I'll post below, mercilessly copy/pasted code, and the closest I can get is one of two…
dizzystar
  • 1,055
  • 12
  • 22
5
votes
1 answer

When using clojure's korma sqlite3 helpers, what's the default path for the sqlite3 database?

When using korma.db, defdb can take a sqlite3 helper to establish a connexion to a sqlite3 database. However, I've tried placing the database on the root of the project directory, alongside project.clj, and on the resources directory, but when I try…
user3112185
  • 101
  • 5
4
votes
1 answer

Inserting db rows with Korma

I have a DB table that uses the following schema: CREATE TABLE users (id SERIAL PRIMARY KEY, username TEXT UNIQUE NOT NULL, password TEXT NOT NULL, email TEXT NOT NULL, admin BOOLEAN NOT NULL, active BOOLEAN NOT NULL, created DATE NOT…
Rom1
  • 3,167
  • 2
  • 22
  • 39
4
votes
0 answers

Insert many-to-many relations in one transaction using Korma

I have 2 models with many-to-many relationship like the next: (declare organisations) (defentity users (many-to-many organisations :users_organisations {:lfk :user_id, :rfk :organisation_id})) (defentity organisations …
Featalion
  • 647
  • 3
  • 9
4
votes
1 answer

How to convert korma select results to json for a rest service (compojure)?

I am using compojure, cheshire and korma (and postgre db) for creating a rest service. I've created a table with two string fields (name and description) with such structure: (defentity posts (pk :id) (table :posts) (entity-fields :name…
Curiosity
  • 651
  • 1
  • 5
  • 12
4
votes
1 answer

Sanitising database inputs in Clojure with Korma

I'm using Korma behind a RESTful API, and it occurs to me that I'm passing user-submitted values through to my (insert)calls. Is there a nice way in Clojure to protect against SQL injection attacks? Korma generates SQL in a pretty straightforward…
Conan
  • 2,288
  • 1
  • 28
  • 42
4
votes
1 answer

Select no fields from table in Korma

I'm trying to do a join across a number of tables (three plus a join table in the middle). I think korma is lazily evaluating the last join. What I'm trying to do is to add a condition that restricts the results of the first table in the join, but…
Conan
  • 2,288
  • 1
  • 28
  • 42
4
votes
1 answer

Why eval works where macro doesn't when building WHERE conditions in Korma

I'm trying to dynamically add WHERE conditions to Korma SQL query (-> the-query (where {:archived false}) (add-where-conditions params) (limit 200) (select)) I'm trying to dynamically build call to korma's where function. The call…
jkj
  • 2,561
  • 1
  • 17
  • 24
4
votes
3 answers

How to select default fields in korma?

Assume you have already done a defdb. I have a table "items" which has two fields, "id" (PK) and "item". I want to set up an entity so that whenever I select it, I only get the entries in "item". Judging by the documentation I thought…
ToBeReplaced
  • 3,334
  • 2
  • 26
  • 42
4
votes
1 answer

How to configure transient fields with Korma

I am using Clojure with korma to store Clojure maps in a Mysql database, e.g storing maps with this structure: (defentity users (table :user) (entity-fields :email :password :name)) In a table with four…
Goran Jovic
  • 9,418
  • 3
  • 43
  • 75
3
votes
1 answer

Imitate partitions/window functions in sqlkorma

I am trying to call the equivalent of this function using sqlkorma, and have not found the equivalent of a partition in the documentation (http://sqlkorma.com/docs): SELECT * FROM ( SELECT DISTINCT cgi, scgi, c.id, c.name, c.address,…
Monica
  • 41
  • 7
3
votes
1 answer

Database mocking in Clojure tests

How can I mock my postgres database for testing? My application is very simple, but I cannot find a good way to mock my database for tests. In Java I usualy use HSQLDB, but there is a solution in Clojure? This is my project file. (defproject…
Victor
  • 8,309
  • 14
  • 80
  • 129
1
2 3 4 5