mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
FAQ: How do I open a database stored as a resource of my application?
This commit is contained in:
1 parent
cfb987e7e3
commit
63a6ef021a
1 file changed
+2
-2
@@ -2372,10 +2372,10 @@ FAQ
|
||||
If your application does not need to modify the database, then open a [database queue](#database-queues) to your resource, making sure the connection is read-only:
|
||||
|
||||
```swift
|
||||
let dbURL = NSBundle.mainBundle().URLForResource("db", withExtension: "sqlite")
|
||||
var configuration = Configuration()
|
||||
configuration.readonly = true
|
||||
let dbQueue = DatabaseQueue(dbURL.path, configuration: configuration)
|
||||
let dbPath = NSBundle.mainBundle().URLForResource("db", withExtension: "sqlite")!.path!
|
||||
let dbQueue = DatabaseQueue(path: dbPath, configuration: configuration)
|
||||
```
|
||||
|
||||
If the application should modify the database, then you need to copy it to a place where it can be modified. For example, in the Documents folder:
|
||||
|
||||
Reference in new issue
Block a user