let file_url = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor:nil,create: false).appendingPathComponent("asd.db") var db:OpaquePointer? = nil if sqlite3_open(file_url.path, &db) == SQLITE_OK { print("Successfully opened connection database!!") var q:OpaquePointer? = nil if sqlite3_prepare_v2(db, "SELECT * FROM aaa", -1, &q, nil) == SQLITE_OK { if sqlite3_step(q) == SQLITE_ROW { let res = sqlite3_column_text(q, 1) let name = String(cString: res!) } else { print("ERROR1!!!!!") } } else { print("ERROR!2!!!!") } }
I have database file named "asd.db" in the proejct and I am trying to open and read data from the database.
I don't know why but sqlite3_open in not able to find my database file, so it's creates new one without my tables.
How can I fix it?