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.
- Open Source iOS Library Providing A Blocks Driven Syntax For Working With SQLite Databases
- Open Source: Active Record Library For SQLite Databases In iOS Apps
- Open Source Core Data Alternative For Those Who Want Direct SQL Access
- Tutorial: Easy iOS Databases With SQLite and FMDB
- Extensive Open Source Swift Based Core Data Wrapper With A MagicalRecord And Linq Inspired Syntax
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.




