SwiftQL lets you write SQL queries using familiar type-safe Swift syntax:
let statement = sql { schema in
let person = schema.table(Person.self)
Select(person)
From(person)
Where(person.name == "Fred" && person.age < 65)
}
This is equivalent to:
SELECT *
FROM Person
WHERE person.name == 'Fred'
AND person.age < 65
Please see more examples in the GitHub repository. Contributions and feedback are welcome.
SwiftQL on GitHub
SwiftQL currently supports:
SELECT
INSERT
UPDATE
CREATE
DELETE
WHERE
GROUP BY
ORDER BY
JOIN
IIF and CASE/WHEN/THEN
Subqueries
Common table expressions
Aggregate functions (min, max, sum, count, average)
Custom functions
...and many other features.
SwiftQL is under active development. The goal is to support the SQLite API, and eventually provide backends for other RDMS (Postgres, MSSQL, etc).