I'm trying to use Sqlite.swift to manage the database in my iOS app. But for some reason insert does not work, stupidly comes into catch and does not write anything to the database. Although the table successfully created
Here is the approximate code that I use (as written in the tutorial) `
import SQLite let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! db = try Connection("\(path)/my_db.sqlite3") let users = Table("users") let id = Expression<Int64>("id") let name = Expression<String?>("name") let email = Expression<String>("email") try db.run(users.create { t in t.column(id, primaryKey: true) t.column(name) t.column(email, unique: true) }) // CREATE TABLE "users" ( // "id" INTEGER PRIMARY KEY NOT NULL, // "name" TEXT, // "email" TEXT NOT NULL UNIQUE // ) do { let insert = users.insert(name <- "Alice", email <- "alice@mac.com") let rowid = try db.run(insert) } catch{ print("Not inserted") } Maybe I missed something or something else should be used for databases in iOS?