If this helps, I created an elegant SQLite library, fully written in Swift, called SwiftData .
Some of its features:
- Bind objects to SQL string
- Transaction and savepoint support
- Embedded Error Handling
- Fully thread safe by default
It provides an easy way to make “changes” (for example, INSERT, UPDATE, DELETE, etc.):
if let err = SD.executeChange("INSERT INTO Cities (Name, Population, IsWarm, FoundedIn) VALUES ('Toronto', 2615060, 0, '1793-08-27')") {
and "queries" (e.g. SELECT):
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)") } } }
Along with many other features!
You can check it out here.
source share