Totally, that’s fair! For now, DBCollections is an experiment: can we just use existing Julia data manipulation functions for working with SQL databases?
Turns out the answer is “yes”, as DBCollections demonstrate. That’s why this thread!
But it’s definitely not a fleshed out implementation, needless to say about sparse documentation.
I’ve been using DBCollections for DuckDB and MySQL databases during the past weeks, and find it convenient and useful. Doesn’t mean it will be useful for you specifically!
Sorry, I jumped straight into what DBCollections does in the first post, and didn’t explain the functions/macros from other packages. The reason is they aren’t specific to databases and defined elsewhere: @p
in DataPipes.jl, @o
in Accessors.jl.
One can use DBCollections without this syntactic sugar, it’s just less convenient. For example, filter(Base.Fix2(>, 0) ∘ PropertyLens(:a), data)
works whenever data
is a regular Julia collection of elements: it selects those x
with x.a > 0
. With DBCollections, the same code works for data
being an SQL table!
@o
simply lets you write the inner function in a more readable way: filter((@o _.a > 0), data)
.
And @p
gets you composable piping, @p data |> filter(@o _.a > 0) |> ...
.
Again, both aren’t directly related to DBCollections, just convenient to be used together.