Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Searching database for specific row with sqlite.swift

I read a specific row in my database. I used the filter query but all I get is the following:

Table(clauses: SQLite.QueryClauses(select: (false, [SQLite.Expression<()>(template: "*", bindings: [])]), from: ("users", nil, nil), join: [], filters: Optional(SQLite.Expression<Swift.Optional<Swift.Bool>>(template: "(\"id\" = ?)", bindings: [Optional(6523)])), group: nil, order: [], limit: nil))

This is my query:

let query = users.filter(id == 6523)
print(query)

Where is my mistake?

like image 618
MotoxX Avatar asked Feb 08 '23 04:02

MotoxX


1 Answers

Ok, sorted the issue myself. I used the prepare function. See code below

let query = users.filter(id == 6523)
for user in try db.prepare(query) { 
   print("id: \(user[name])") 
}
like image 51
MotoxX Avatar answered Mar 05 '23 18:03

MotoxX