Open Source Swift Based Library For Working With SQLite Databases

A couple of months ago I mentioned a Swift based library for working with Core Data called QueryKit.

Here’s a Swift based library that makes it easier to work with SQLite databases called SwiftData from Ryan Fowler.

The features of SwiftData include:

– Many different helper methods for common tasks
– Queries are returned as an array
– Direct execution of SQL statements
– Error handling
– Thread safe

This is an example showing how to create and print a query:


let (resultSet, err) = SD.executeQuery("SELECT * FROM Cities")
if err != nil {
    //there was an error during the query, handle it here
} else {
    for row in resultSet {
        if let name = row["Name"]?.asString() {
            println("The City name is: \(name)")
        }
        if let population = row["Population"]?.asInt() {
            println("The population is: \(population)")
        }
        if let isWarm = row["IsWarm"]?.asBool() {
            if isWarm {
                println("The city is warm")
            } else {
                println("The city is cold")
            }
        }
        if let foundedIn = row["FoundedIn"]?.asDate() {
            println("The city was founded in: \(foundedIn)")
        }
    }
}

You can find SwiftData on Github here.

A great library for working with SQLite databases.

FacebookTwitterDiggStumbleUponGoogle Plus

Original article: Open Source Swift Based Library For Working With SQLite Databases

©2014 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *