Swift 3 sqlite / using database?

I'm new to fast encoding, but I'm working on an application that really needs a database for a large amount of data. I looked at coredata, and it seems this is not what I need. I have a complete database that works with sql statements, really what I am looking for.

There is a lot of information on the Internet about setting up the sqlite database in iOS, but it seems that everything has changed since the advent of Swift 3 and xcode 8.

I'm not sure how to actually “connect” to the sqlite database from the project, all the code I saw requires a “path” to the database that is on the computer, but when the application is sent, users obviously will not be able to get access to this path. Do you need to create a .sqlite file in a project?

Thank you for your help!

+4
source share
1 answer

You definitely need a database file, and this database file has a path. Even on iOS.

Now, if users of your application can modify the database, it’s likely that the database file is stored in the Documents folder, a special folder available to all iOS applications. Create a path to the file inside this folder and open the database on this path. SQLite will create an empty database if necessary.

(, ), , , . - , . NSBundle.main .

GRDB.swift : https://github.com/groue/GRDB.swift. Swift 2.2/2.3/3.0.

+2

Source: https://habr.com/ru/post/1648192/


All Articles