https://github.com/katrix/dataprism
A new FRM with focus on Higher Kinded Data
https://github.com/katrix/dataprism
Last synced: about 1 year ago
JSON representation
A new FRM with focus on Higher Kinded Data
- Host: GitHub
- URL: https://github.com/katrix/dataprism
- Owner: Katrix
- Created: 2022-07-31T17:59:06.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-16T18:51:55.000Z (over 1 year ago)
- Last Synced: 2025-03-16T19:47:12.401Z (over 1 year ago)
- Language: Scala
- Homepage: https://dataprism.katsstuff.net/
- Size: 12.5 MB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DataPrism
*A new FRM with focus on Higher Kinded Data*
DataPrism is an SQL query construction library built to take full advantage of
the power of higher kinded data. DataPrism builds
on [`perspective`](https://github.com/Katrix/perspective)
and the tools it provides for programming with higher kinded data.
The power of higher kinded data makes DataPrism more flexible than other Scala SQL libraries.
Want to sometimes leave out a column? You can do that. Want to return a List from a query?
Sure thing.
DataPrism works with both Java's JDBC and Skunk.
Add DataPrism to your project by adding these statements to your `build.sbt` file.
```scala
// For JDBC
libraryDependencies += "net.katsstuff" %% "dataprism-jdbc" % "{{versions.dataprism}}"
// For Skunk
libraryDependencies += "net.katsstuff" %% "dataprism-skunk" % "{{versions.dataprism}}"
```
*DataPrism is currently early in development, but feel free to try it out and
report bugs and errors.*
## Showcase
See [the docs](https://dataprism.katsstuff.net/index.html) for a full explanation and walkthrough on
how to use DataPrism.
```scala
case class HomeK[F[_]](
owner: F[UUID],
name: F[String],
createdAt: F[Instant],
updatedAt: F[Instant],
x: F[Double],
y: F[Double],
z: F[Double],
yaw: F[Float],
pitch: F[Float],
worldUuid: F[UUID]
)
object HomeK {
import dataprism.jdbc.sql.JdbcType
import dataprism.jdbc.sql.PostgresJdbcTypes.*
val table: Table[HomeK, JdbcType] = Table(
"homes",
HomeK(
owner = Column("owner", uuid),
name = Column("name", text),
createdAt = Column("created_at", javaTime.timestamptz),
updatedAt = Column("updated_at", javaTime.timestamptz),
x = Column("x", doublePrecision),
y = Column("y", doublePrecision),
z = Column("z", doublePrecision),
yaw = Column("yaw", real),
pitch = Column("pitch", real),
worldUuid = Column("world_uuid", uuid)
)
)
given KMacros.ApplyTraverseKC[HomeK] = KMacros.deriveApplyTraverseKC[HomeK]
}
Query.from(HomeK.table).map(homes => (homes.owner, homes.name))
Query
.from(HomeK.table)
.groupBy(homes => (homes.owner, homes.name))((grouped, homes) =>
(
grouped._1,
grouped._2,
homes.x.arrayAgg,
homes.y.arrayAgg,
homes.z.arrayAgg
)
)
```