Bold: A SQLite framework written in Swift

Oct 30, 2016

I do like SQLite a lot. Because of that I wrote a litte SQLite framework when Swift came out - in order to learn Swift. This little framework is called Bold. I have always it up to date. During the last few weeks I have used it myself in a private project. During the last couple of days I added a few nice little features that I like but first things first:

Checkout Bold at GitHub

One of the cool features are asynchronous transactions. They work like this:

let db = Database(URL:":memory:")

db.async { transaction in 
  let args = ["firstName" : "Christian", 
              "lastName" : "Kienle"]
  let query = "INSERT INTO Person (firstName, lastName) " +
              "VALUES (:firstName, :lastName)"
  db.update(query, arguments: args)
  // call transaction.rollback() to perform a rollback

Cool isn’t it? I have also added subscripting support to the Row-structure:

let result = db.query(query: "SELECT firstName, lastName FROM Person")
for row in result {
    let firstName = row["firstName"].string
    let lastName = row["lastName"].string
    println("firstName: \(firstName)")
    println("lastName: \(lastName)")
// The result is automatically closed after a complete iteration.

Checkout Bold at GitHub