Originally created by @mrichtsfeld on GitHub (May 18, 2017).
Hi @JohnEstropia,
Is there any way to find out if a database already exists before adding it? E.g. I need to do some pre-setup stuff if the user had no database.
Thanks a lot
Originally created by @mrichtsfeld on GitHub (May 18, 2017).
Hi @JohnEstropia,
Is there any way to find out if a database already exists before adding it? E.g. I need to do some pre-setup stuff if the user had no database.
Thanks a lot
adam
added the question label 2025-12-29 18:23:25 +01:00
@mrichtsfeld If you just need to check if the file exists, you can use SQLiteStore to query FileManager:
letstorage=SQLiteStore(fileName:"my.sqlite")ifFileManager.default.fileExists(atPath:storage.fileURL.path){// ... pre setup stuff}
@JohnEstropia commented on GitHub (May 18, 2017):
@mrichtsfeld If you just need to check if the file exists, you can use `SQLiteStore` to query `FileManager`:
```swift
let storage = SQLiteStore(fileName: "my.sqlite")
if FileManager.default.fileExists(atPath: storage.fileURL.path) {
// ... pre setup stuff
}
```
@HristiyanZahariev You can initialize an SQLiteStore with your own file URL:
CoreStore.defaultStack=DataStack(xcodeModelName:"Model",// your xcdatamodeld namebundle:Bundle(for:type(of:self)))tryCoreStore.addStorageAndWait(SQLiteStore(fileURL:yourFileURL// here))
@JohnEstropia commented on GitHub (Jan 22, 2018):
@HristiyanZahariev You can initialize an SQLiteStore with your own file URL:
```swift
CoreStore.defaultStack = DataStack(
xcodeModelName: "Model", // your xcdatamodeld name
bundle: Bundle(for: type(of: self))
)
try CoreStore.addStorageAndWait(
SQLiteStore(
fileURL: yourFileURL // here
)
)
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @mrichtsfeld on GitHub (May 18, 2017).
Hi @JohnEstropia,
Is there any way to find out if a database already exists before adding it? E.g. I need to do some pre-setup stuff if the user had no database.
Thanks a lot
@JohnEstropia commented on GitHub (May 18, 2017):
@mrichtsfeld If you just need to check if the file exists, you can use
SQLiteStoreto queryFileManager:@mrichtsfeld commented on GitHub (May 18, 2017):
@JohnEstropia that works perfect for me. Thanks for the hint.
@HristiyanZahariev commented on GitHub (Jan 22, 2018):
What does pre setup stuff mean? How am I able to use this sqlite database?
@JohnEstropia commented on GitHub (Jan 22, 2018):
@HristiyanZahariev You can initialize an SQLiteStore with your own file URL: