sql

m3tti 2024-09-25T13:45:33.216419Z

how do you handle big tables with multple columns in an execute! block?

seancorfield 2024-09-25T15:16:26.723939Z

Not sure what you're asking here? Execute! accepts regular SQL...

m3tti 2024-09-25T15:37:25.092379Z

The real question was :D i have an insert into with lots of fields 16+ how can i do the insert dynamically is that even possible ootb or do i have to write that on my own. Something like

(defn insert [fields]
   (execute! db ["insert into(all, my, fields, ...) values (?,?,?,...)" fields]))

seancorfield 2024-09-25T16:11:32.901569Z

(next.jdbc.sql/insert! db :table {hash map of data}) perhaps?

❤️ 1
seancorfield 2024-09-25T16:12:32.317339Z

Or maybe look at HoneySQL to generate SQL for you?

m3tti 2024-09-25T16:24:55.885909Z

Exactly what i was looking for sorry for not looking that up on my own

seancorfield 2024-09-25T16:26:05.443299Z

Here's all the built-in "friendly" functions that generate SQL: https://cljdoc.org/d/com.github.seancorfield/next.jdbc/1.3.939/doc/getting-started/friendly-sql-functions

❤️ 1
seancorfield 2024-09-25T16:26:18.680059Z

If you need something more sophisticated, use HoneySQL.

m3tti 2024-09-25T16:34:21.418939Z

No clue why but i wanted to avoid it as long as possible. Guess i'll end up with it like all others before.

m3tti 2024-09-25T18:38:02.108319Z

And this is exactly what i had in mind while thinking about the problemhow to implement it https://github.com/seancorfield/next-jdbc/blob/a6ecdee5ac14ecebb04164b7a856db50b611ae12/src/next/jdbc/sql/builder.clj#L125

m3tti 2024-09-27T07:56:30.452669Z

as i allready pointed out 😄 i'm at the point that i'll include honeysql 😄

👍🏻 1
seancorfield 2024-09-27T16:26:37.839029Z

Lots of help available in #honeysql (and here for the non-HoneySQL parts)! 🙂