Get Updates By E-mail 

Article Written By:
Johann Dowa

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.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments