ScalaSql: query SQL databases via concise, type-safe, and familiar case classes and collection operations


I just cut the first release of my new Scala database query library

The readme and docs have a lot more detailed information that I could write here, so please take a look and try it out! It’s a new library, so there may be some rough edges, but I hope people will find it competitive at providing an easier alternative to the other database query libraries in the Scala ecosystem today

You can see an example of it integrated with the Cask web framework here:


Looking quickly at it, it seems quite similar to my own SQL library I’ve been working on for some time. Interesting

1 Like

@Katrix yes, it does seem to use the same higher-kinded case classes to model table rows. If you are interested we could definitely collaborate, I currently lack Scala 3 macro expertise but given your work with DataPrism it shouldn’t be too hard to get ScalaSql onto Scala, and then ScalaSql on 2.13/3.x could satisfy the use case that both ScalaSql and DataPrism handle today

I’d definitively be interested in helping out a bit, but I don’t know how much is transferable.

While the two libraries both use higher kinded data, the extent of their usage is quite different. DataPrism is HKD first, and then “translates” its operations down to work with tuples and other types eventually too. ScalaSql meanwhile seems to mostly just use HKD for the case classes.

You could probably still use DataPrism’s macros as a baseline of sorts. In DataPrism/common/src/main/scala/dataprism/KMacros.scala at 3241ac96e56f3f6ec222e9a9335f4d80eab66b2c · Katrix/DataPrism · GitHub I would imagine MirrorProductK and getInstancesForFields would be the things you would be interested in. Although you might not even need getInstancesForFields as it is made to work with nested or ‘weird’ fields like NestedData[F] or Option[F[Int]], and I’m unsure if you support that.

If you don’t then MirrorProductK might be all you need. No macros needed.

1 Like