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

SQL don't found table Xcode 9 #53

Closed
jmanoel opened this issue Aug 8, 2017 · 5 comments
Closed

SQL don't found table Xcode 9 #53

jmanoel opened this issue Aug 8, 2017 · 5 comments

Comments

@jmanoel
Copy link

jmanoel commented Aug 8, 2017

Hello. I have an issue,

when I try to make a query, I got a response that has no such table found for example:

SQLiteDB opened!
2017-08-08 09:40:02.072893-0300 AJ3[73215:8322823] SQLiteDB - failed to prepare SQL: SELECT * from servers, Error: no such table: servers

but the data.db file is present and has the table servers. Could you help me with it?

@jmanoel
Copy link
Author

jmanoel commented Aug 8, 2017

When access the method prepare on SQLiteDB.swift it's returned 1 that indicates error:

let result = sqlite3_prepare_v2(self.db, cSql!, -1, &stmt, nil)

btw if I do a select to know the sqlite version. The result is 0 that indicates that everything is ok

@jmanoel
Copy link
Author

jmanoel commented Aug 8, 2017

On Xcode 8.3.2 works fine

@jmanoel
Copy link
Author

jmanoel commented Aug 8, 2017

I Found that the error is because when you compile the app for the first time, it fails to copy writable version of DB.

@jmanoel
Copy link
Author

jmanoel commented Aug 8, 2017

The let from = (rp as NSString).appendingPathComponent(DB_NAME) doesn't exists on Xcode 9. I don't know if is a beta Xcode bug or apple changed the way to insert files on xcode

@FahimF
Copy link
Owner

FahimF commented Aug 12, 2017

Not sure what is going on at your end but when I test the code over here it works fine. And just FYI - I don't know what you mean when you say appendingPathComponent does not exist on Xcode 9 - that method is still present in iOS 11 and works fine. Otherwise you would get a compiler error when you compile the project.

I tested the code at my end on the latest Xcode 9 beta (beta 5) and everything works as it should. However, if you are using a bundled database in the app, then you need to change the AppDelegate line which opens the DB from - db.openDB(copyFile:false) to db.openDB(copyFile:true). Otherwise, the bundled file will not be copied over. This is a change for something else that I'm working on which should not have been added to the sample file.

@FahimF FahimF closed this as completed Aug 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants