U
U
uzolenta2018-12-02 18:43:00
iOS
uzolenta, 2018-12-02 18:43:00

Connect sqlite file to Swift application?

Hello!
Can you please tell me how to correctly add my sqlite database file (already with data, not re-create) to the project/application? And how it will be necessary to address this file.
Working with the database itself - everything is OK, the essence is in accessing the file.
I 'm using the latest XCode, Swift 4.
If possible, please provide more details.
How I do now:

let fileURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
            .appendingPathComponent("base.sqlite")
        print("fileUIrl: ")
        print(fileURL)
        
        var db: OpaquePointer?
        if sqlite3_open(fileURL.path, &db) != SQLITE_OK {
            print("error opening database")
        } else { print ("GOOD DATABASE") }

Accordingly, each time you have to throw a file into the simulator folder. And as soon as I started testing the application on a cell phone, the problem arose that it was not clear how to attach it to the project so that the application would be compiled with this database file.
Thank you very much in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2018-12-02
@uzolenta

so put the finished base in resources and all business.
https://stackoverflow.com/questions/46231153/how-t...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question