bah, I need to process some html (specifically to pull data out of a table.) I know there is a jsoup pod... but is there anything lighter weight?
Regex for the win... (def rows (drop 1 (clojure.string/split table-contents #"<tr class=\"\w+\">")))
#!/usr/bin/env bb
(require '[babashka.pods :as pods])
(pods/load-pod 'retrogradeorbit/bootleg "0.1.9")
(require '[pod.retrogradeorbit.bootleg.utils :as utils])
(-> "<html><p>Hello</p></html>"
(utils/convert-to :hiccup))
;; => [:html [:p "Hello"]]
This pod will self-install itself
Thanks, I now realize I need to do even more parsing... I have to pull data out of a simple form. Life is too short to parse HTML with regex and indexOf and subs() - I will try the pod.
I am going to include test.check as a preparation for including clojure.spec in babashka. https://github.com/babashka/babashka/pull/717 clojure.spec will be included when it's clear what happens to alpha and version 2, but I've already made a start with this as a feature flag, which is disabled by default.
Released babashka 0.2.8 with additional built-in libraries: - core.match (much requested) - clojure.test.check (prep for including spec once it comes out of alpha) - hiccup (who doesn't use it?) https://github.com/babashka/babashka/blob/master/CHANGELOG.md#v028
Awesome!
Whatโs the recommended way to connect to a postgres db via babashka?
@jayzawrotny I recommend https://github.com/babashka/babashka-sql-pods/
Welcome btw!
Thanks on both accounts ๐
./test.clj
/home1/[redacted]/.babashka/pods/repository/org.babashka/postgresql/0.0.1/pod-babashka-postgresql: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home1/[redacted]/.babashka/pods/repository/org.babashka/postgresql/0.0.1/pod-babashka-postgresql)
Is there a way to get a static binary for this or should I try a different route?@jayzawrotny Are you running this in an alpine docker container?
Itโs a shared hosting environment as a cgi-script for learning\experimenting.
currently we don't have a static version of this pod. theoretically it's possible
you can compile it yourself locally, it's not hard
the other way of connecting to postgres would be to shell out to psql
There is even a library around shelling out to psql for bb: https://github.com/DarinDouglass/clj-psql
But this was before there were pods.
Great! I did see that library mentioned in the docs but was curious about alternatives. The psql bin does exist on this server so shelling out should be doable, but local compile then uploading might be more performant Iโm guessing? Any docs on compiling it locally? Should I setup a docker container to match the host environment?
And there is another way: there is a feature flag in babashka itself which includes the postgres driver. So you could have a static babashka with postgres support and you could then upload this to your shared env.
I did upload the static babashka already
@jayzawrotny yeah, so you could compile the pod statically, or you could compile babashka statically with pg support enabled
then you would have it built into bb, you can require next.jdbc directly without the pod
That could work too for sure. This is quite exciting!
@jayzawrotny So here are the build docs: - static: https://github.com/babashka/babashka/blob/master/doc/build.md#static - postgres: https://github.com/babashka/babashka/blob/master/doc/build.md#postgresql
Thanks very much!
Be sure to use GraalVM java11-20.3.0.
After a bit of research Iโm going to start with compiling the pods. As it stands, Iโm unable to use any pods at runtime so tackling this is a must for any definitive guide. Fortunately those links gave me enough info to get that going.