Simple
Querying data is straightforward.
It's not required to know advanced functional type classes to use the library.
Seamless
Read and write to various data sources seamlessly.
Scala QL supports CSV, JSON, Excel, HTML, and more!
Static types
Benefit from having statically typed queries!
Scala QL allows working with plain-old case classes, which makes your code type-checked
Get started easily
Here is an example of how to query data from various sources.
import scalaql._
import java.nio.charset.StandardCharsets
import java.nio.file.Paths
val query: Query[From[Student] with From[Faculty], FacultyStats] =
select[Student]
.where(_.age >= 18)
.join(select[Faculty])
.on(_.faculty == _.name)
.groupBy { case (_, faculty) => faculty.name }
.aggregate { (faculty, studentsWithFaculties) =>
studentsWithFaculties
.avgBy { case (student, _) => student.grade }
.map(avgGrade => FacultyStats(faculty, avgGrade))
}
val studentsPath = Paths.get("students.csv")
val facultiesPath = Paths.get("faculties.json")
val outPath = Paths.get("faculty_stats.csv")
query
.foreach(
csv.write[FacultyStats].file(outPath)
)
.run(
from(
csv.read[Student].file(studentsPath)
) & from(
json.read[Faculty].file(facultiesPath)
)
)