Type-safe & compile-time-checked wrapper around the Cassandra driver. That allows you to write raw CQL queries like:

Programming language: Scala
License: Apache License 2.0
Tags: Database     CQL     Cassandra     Type-Safe     Schema-Safe     DB Driver    
Latest version: v0.5

Troy alternatives and similar packages

Based on the "Database" category.
Alternatively, view Troy alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Troy or a related project?

Add another 'Database' Package


Build Status Gitter Coverage Status


Last stable code (as preseneted in ScalaExchange 2016) under "v0.5" tag.

The new approach (as presented in ScalaSwarm 2017, and Scala.World 2017) is here (in master branch), however is highly unstable at the moment. If you want something to play with, I recommend checking our POC instead.

What is Troy?

Type-safe & compile-time-checked wrapper around the Cassandra driver. That allows you to write raw CQL queries like:

@schemasafe val q = 
  query[Search, Result]("""
    SELECT x, y, z
    FROM test
    WHERE x = ? AND y = ?;

Validating them against your schema, defined as below:

@schema object Schema extends SchemaFromString(
    CREATE TABLE test (
      x text PRIMARY KEY,
      y int,
      z list<text>

and showing errors at compile-time like:

Main.scala:15: Column 'ops_typo' not found in table 'test.posts' OR Main.scala:15: Incompatible column type Int <--> troy.driver.CassandraDataType.Text

Check our [examples](examples) for more usecases.

Compile-time Codec registery

Troy wraps Cassandra's codecs in Typeclasses, to allow picking the correct codec at compile-time, rather than runtime. This is also extensible, by defining an implicit HasTypeCodec[YourType, CassandraType].

Optional columns

Troy handles optional values automatically, by wrapping Cassandra's codec with null checking. All you need to do is define your classes to contain Option[T] like.

case class Post(id: UUID, title: Option[String])

CQL Syntax

Troy targets (but not fully implements) CQL v3.4.3


Troy is currently is very early stage, testing, issues and contributions are very welcome.


This code is open source software licensed under the [Apache 2.0 License]("http://www.apache.org/licenses/LICENSE-2.0.html").

*Note that all licence references and agreements mentioned in the Troy README section above are relevant to that project's source code only.