I am trying to understand why I get "Use of unresolved identifier 'db'" below. The connection works but I can't see db outside the do{}. Can someone please explain this and how to correct it? I think it is the scope of the variable db?
func openTheDB2() -> String {
do {
let db = try Connection("/Users/benniewarren/Desktop/database.sqlite")
}
catch {
print("Failure2")
}
let users = Table("users")
try db.run(users.create { t in // CREATE TABLE "users" (
t.column(id, primaryKey: true) // "id" INTEGER PRIMARY KEY NOT NULL,
t.column(email, unique: true) // "email" TEXT UNIQUE NOT NULL,
t.column(name) // "name" TEXT
}) // )
return "Ok2"
}