Reputation: 2644
I'm trying to debug some sqlite.swift statements that aren't delivering the results I expect.
The documentation shows examples of SQL in comments.
for user in try db.prepare(users.select(id, email)) {
print("id: \(user[id]), email: \(user[email])")
// id: 1, email: [email protected]
}
// SELECT "id", "email" FROM "users"
How do I get the statement to print that SQL?
print("\(users.select(id, email))")
does not give me SQL. Am I overlooking something in the documentation?
Upvotes: 0
Views: 1344
Reputation: 1328
If you want to see the SQL being executed then print(query.asSQL())
let query = dbTable
.filter(dbSourceKey == Int64(minElement))
.filter(dbTargetKey == Int64(maxElement))
print(query.asSQL())//Will show SQL statement
Upvotes: 6
Reputation: 4044
The following command will print all SQL statements:
db.trace(print)
See https://github.com/stephencelis/SQLite.swift/blob/master/Documentation/Index.md#logging
Upvotes: 3