Search code examples
iosswiftsqlitegrdb

SQLite error 14 in ViewController


import GRDB

class MyView: UIViewController{
    override func viewDidLoad() {
    super.viewDidLoad()
        do{
            let dbPool = try DatabasePool(path: "/path/to/database.sqlite")
        }catch let error{
        print(error)
    }
    }
}

error is print SQLite error 14

what is SQLite error 14?

first use GRDB and first Call SqlLite

Why raise Error?

Ios 11.0 Swift 4.0 Grdb 2.10.0

Build to Iphone8 Simulater


Solution

  • SQLite error code 14 means

    Unable to open the database file.

    You can get the description from there: https://sqlite.org/c3ref/c_abort.html

    For your question, what exactly the path is? Are you hard coded the path? Don't hard code the path, use pattern like

    let path = NSHomeDirectory() + "/Documents/database.sqlite"
    

    to get your database's path to see if your issue can be solved.