Skip to content

meraki/scalaqlite

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scalaqlite - A native Scala library for using Sqlite3

I recently wanted to use Sqlite from within Scala for a little project I'm
working on, and I couldn't find any Scala libraries for doing so.  There are
Java libraries out there, but they're all very Java-ish, and I'm not crazy
about Java.

This library is intended to give a very Scala-ish interface to Sqlite.  For
example, you can use the follwing code to print all the rows in table "foo"
with the columns separated by spaces:

    for (row <- db.query("SELECT * FROM foo;"))
        println(row.map(_.toString).mkString(" "))

Or if you want to add up the values of the first column, you can do this:

    for (row <- db.query("SELECT * FROM foo;")) {
        row(0) match {
            case SqlInt(i) => sum += i
            case _ => throw new Exception("expected an int")
        }
    }

I'm pretty new to Scala, and I haven't written much Java in the last few
years, so this library is definitely a work in progress.  Please send
constructive feedback, and please be tolerant of interface changes as the
library matures.

Note that sbt doesn't handle setting java.library.path yet, so you have to run
the tests like this:

  LD_LIBRARY_PATH=./target/native sbt test

If you want to avoid compiling the native code and setting LD_LIBRARY_PATH, at
the cost of some performance, check out the jna branch.

Sean

About

A native Scala library for using Sqlite3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scala 57.2%
  • C++ 25.3%
  • Java 11.4%
  • Makefile 3.1%
  • Ruby 3.0%