Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to open database file #3

Closed
LazyTravis opened this issue Oct 25, 2014 · 6 comments
Closed

unable to open database file #3

LazyTravis opened this issue Oct 25, 2014 · 6 comments

Comments

@LazyTravis
Copy link

when I try to use
let db=Database("path/to/db.sqlite3")

it pop a error said
fatal error: unable to open database file: file /Users/apple/Desktop/SQLite.swift/SQLite Common/Database.swift, line 336

Thanks for your help in advance

@stephencelis
Copy link
Owner

No "thanks in advance" necessary till you give me enough information to troubleshoot :) Please describe your exact setup and how/where your Database file is getting stored. Thanks!

@stephencelis
Copy link
Owner

(If you are actually pasting that line in, you need to replace "path/to/db.sqlite3" to a resolvable path in your application.)

@LazyTravis
Copy link
Author

My Setup is : New project -> single view application - > input product name,do not choose Use Core data(even choose it,still same error)->then choose a place to create.

After that,I do as your screen dumped.

I can run below code.Very strange.My new application is not in the same path of SQLite
let db = Database("")
let db = Database()

I try to write let db = Database("db.sqlite3"),but it still can't work.

@LazyTravis
Copy link
Author

It's the first time to use SQLite,so I have no idea whether need to configure something else.:)

@stephencelis
Copy link
Owner

I should probably have better explicit examples in the README, but the path needs to be a place your app can reach, e.g.:

let path = NSSearchPathForDirectoriesInDomains(
    .DocumentDirectory, .UserDomainMask, true
).first as String

let db = Database("\(path)/db.sqlite3")

If you want to nest the database in a directory, you'll need to create one first.

@LazyTravis
Copy link
Author

Cool,It can works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants