Giter Club home page Giter Club logo

scalaqlite's Introduction

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

scalaqlite's People

Contributors

srhea avatar eatkins avatar spv avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.