Git Product home page Git Product logo

Comments (23)

thomasschoenfeld avatar thomasschoenfeld commented on June 18, 2024

Since the Mac framework was not working, I went ahead and uses the iOS framework. However, I am unable to query anything at all from a connected database. Either, I am just to noob for this or there a still some bug in your wrapper.
bildschirmfoto 2015-01-17 um 17 44 15
The database I am connection to is the Apple iCal Cache database.

from sqlite.swift.

stephencelis avatar stephencelis commented on June 18, 2024

These images do not provide enough context to troubleshoot.

In the first (Mac) project, please provide a screen shot of your entire Xcode project from the "Build Phases" screen.

In the second (iOS) project, please show me the error you're getting on that line, and please show me where you set "ZTITLE".

from sqlite.swift.

thomasschoenfeld avatar thomasschoenfeld commented on June 18, 2024

Hi, lets go with the Mac issue, since this is the one that matters to me.
bildschirmfoto 2015-01-17 um 23 25 37

from sqlite.swift.

stephencelis avatar stephencelis commented on June 18, 2024

Which of the two SQLite.framework files did you drag into the last two areas?

Alternatively, can you try the "universal-framework" branch, which simplifies the build system?

On Jan 17, 2015, at 2:27 PM, thomasschoenfeld [email protected] wrote:

Hi, lets go with the Mac issue, since this is the one that matters to me.


Reply to this email directly or view it on GitHub.

from sqlite.swift.

thomasschoenfeld avatar thomasschoenfeld commented on June 18, 2024

Here is a video of how I set it up. I hope you bare with even if I ask this noobisch questions. Right after adding your framework I build the app. This seems to work. But when I add another playground my database will not be accessed properly.
Here Link to my setup video: https://dl.dropboxusercontent.com/u/107444970/Xcode_and_SQlite.m4v
And here the issue I'm having:
bildschirmfoto 2015-01-18 um 12 37 52

For your previous question: I deleted the older projects already, since they were iOS and Mac mixed with your an other frameworks. Just so I don't have some unwanted stuff flying around.
What I can tell is everything you see in my code in capital letters starting with Z.... are either tables or items / rows of the tables. For example the table ZCALENDARITEM contains all items in you Apple iCal app. ZTITLE would be a row in that table containing the titles of your calendars events.

from sqlite.swift.

stephencelis avatar stephencelis commented on June 18, 2024

@thomasschoenfeld Ah, the problem seen in the video is that you need to have built the framework (for iOS) at least once for a playground to run (see the note I left at the top of the playground)—and even after that, the playground will usually keep that error visible till you edit the playground or quit/relaunch the project.

Beyond that, in your screen shot, above, you're trying to open a database file in a location that playgrounds do not have access to (they're sandboxed).

Please read the "Connecting to a Database" documentation for some examples of places to open databases:

https://github.com/stephencelis/SQLite.swift/blob/master/Documentation/Index.md#connecting-to-a-database

And let me know if you have better luck importing and using SQLite.swift in actual source files in your project (rather than playgrounds).

from sqlite.swift.

thomasschoenfeld avatar thomasschoenfeld commented on June 18, 2024

I am getting started with swift just now. This is why I use playgrounds.
I did as you said. The database is now in the support files dir. I also used your code for the connection. Now I get a different error. However, I am not sure that the database is really connected. I did build, stopped, closed and reopened everything. Still my issue remains.
bildschirmfoto 2015-01-18 um 20 16 46
Again I apologise for bothering you. I can find my way around C/C++ and I am good with applescript. But I am totally new to Xcode projects / frameworkes / etc... And rather than starting with python to get an somewhat good print-out I want to do this in swift to force myself to get into and build my app.
The whole idea is to build an app around my iCal events, which will give me my time worked and some other stuff.

from sqlite.swift.

stephencelis avatar stephencelis commented on June 18, 2024

My recommendation would be to spend less time in the playground right now as you get comfortable. Try pasting this code into your AppDelegate launch code and you should hopefully get better error messages and stack traces.

I'm going to close this issue for now as there don't appear to be any specific bugs being reported.

from sqlite.swift.

ericcgu avatar ericcgu commented on June 18, 2024

I agree with Stephen.

But when you do start a project, here some extra tips:
I use Firefox's SQLite Manager. You can runs scripts on it and theres a nice GUI. Import some fake data using the CSV import option.
Drag your database into your project.
Follow the instructions in the documentation on how to install the framework.
Go to Copy Bundle Resources and add your database.
screen shot 2015-01-18 at 2 05 52 pm

If you only need to read: its super easy: (two lines of code)
let path = NSBundle.mainBundle().pathForResource(kDatabaseName, ofType: kDatabaseType)!
let db = Database(path, readonly: true)
Then follow the docs on how to perform queries.
Good luck.

from sqlite.swift.

thomasschoenfeld avatar thomasschoenfeld commented on June 18, 2024

I tried that and is still not working. Has one of you tried open a sqlite database that way? Because I did exactly as you wrote and I still have issues. I mean, I am new to this, but not that new. If you want, we could do a short remote session. If it works, it would take about 2 Minutes to show me. But honestly I think it will not work.

Or are you saying connection to databases within playground is not supported?

Am 19.01.2015 um 19:19 schrieb Eric Gu (@ericguuu) [email protected]:

I agree with Stephen.

But when you do start a project, here some extra tips:
I use Firefox's SQLite Manager. You can runs scripts on it and theres a nice GUI. Import some fake data using the CSV import option.
Drag your database into your project.
Go to Copy Bundle Resources and add your database.

If you only need to read: its super easy: (two lines of code)
let path = NSBundle.mainBundle().pathForResource(kDatabaseName, ofType: kDatabaseType)!
let db = Database(path, readonly: true)
Then follow the docs on how to perform queries.
Good luck.


Reply to this email directly or view it on GitHub.

from sqlite.swift.

stephencelis avatar stephencelis commented on June 18, 2024

@thomasschoenfeld You should get a very specific assertion message back when running the application (rather than running a playground). Playgrounds don't play nicely with assertions, so it becomes difficult to troubleshoot those cases. Run the application with your code, above, and read the assertion's error message that prints to the Xcode console upon crash.

Beyond that, a playground runs in its own application/bundle/sandbox, so it doesn't have direct access to the resources your app target has access to (including the database file you're trying to open).

See http://stackoverflow.com/questions/24069479/swift-playgrounds-with-uiimage for more info on opening resources from within a playground.

from sqlite.swift.

thomasschoenfeld avatar thomasschoenfeld commented on June 18, 2024

mh…. ok, I tried the most stupid thing I could think of, command line tool :-D an I got this… I saw your other email an will try that as well...

Am 19.01.2015 um 20:53 schrieb Stephen Celis [email protected]:

@thomasschoenfeld You should get a very specific assertion message back when running an application. Playgrounds don't play nicely with assertions, so it becomes difficult to troubleshoot those cases. Run the application with your code, above, and read the assertion's error message that prints to the Xcode console upon crash.


Reply to this email directly or view it on GitHub.

from sqlite.swift.

stephencelis avatar stephencelis commented on June 18, 2024

@thomasschoenfeld Command-line tools in OS X do not support dynamic frameworks, so you'll likely have to embed the SQLite.swift files directly.

See #4.

from sqlite.swift.

thomasschoenfeld avatar thomasschoenfeld commented on June 18, 2024

understood. I tried the other thing that you gave me the link to, the one with the images etc. Still nothing (this time again with an Cocoa App) … It can not be that hard… I think I am doing something very very very stupid which keeps me from getting it to work...

Am 19.01.2015 um 21:06 schrieb Stephen Celis [email protected]:

@thomasschoenfeld Command-line tools in OS X do not support dynamic frameworks, so you'll likely have to embed the SQLite.swift files directly.


Reply to this email directly or view it on GitHub.

from sqlite.swift.

thomasschoenfeld avatar thomasschoenfeld commented on June 18, 2024

ok, so with playgrounds I am not getting anywhere. I also tried another framework and eliminated all „-„ in the folder paths. This seemed to be one issue as well. Now it seems it is being accessed alright, but I now get an fatal error on runtime… It is an Mac App, no playground, and the code is within the AppDelegate just as you suggested.

Am 19.01.2015 um 21:06 schrieb Stephen Celis [email protected]:

@thomasschoenfeld Command-line tools in OS X do not support dynamic frameworks, so you'll likely have to embed the SQLite.swift files directly.


Reply to this email directly or view it on GitHub.

from sqlite.swift.

thomasschoenfeld avatar thomasschoenfeld commented on June 18, 2024

I seem to have an issue with my iCloud account. So here is my last email again…

ok, so with playgrounds I am not getting anywhere. I also tried another framework and eliminated all „-„ in the folder paths. This seemed to be one issue as well. Now it seems it is being accessed alright, but I now get an fatal error on runtime… It is an Mac App, no playground, and the code is within the AppDelegate just as you suggested.

I think I am almost there...

Am 19.01.2015 um 21:06 schrieb Stephen Celis [email protected]:

@thomasschoenfeld Command-line tools in OS X do not support dynamic frameworks, so you'll likely have to embed the SQLite.swift files directly.


Reply to this email directly or view it on GitHub.

from sqlite.swift.

stephencelis avatar stephencelis commented on June 18, 2024

Please provide as much information as possible if you want help troubleshooting, e.g.:

  • The actual fatal error message you're getting
  • A sample project (and/or playground) with the error intact

You're unfortunately not providing enough information to really troubleshoot the issue.

from sqlite.swift.

thomasschoenfeld avatar thomasschoenfeld commented on June 18, 2024

the error reads:
fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)

here is the whole project (including the database).
https://dl.dropboxusercontent.com/u/107444970/Archiv.zip

If you think, everything is ok, then maybe for whatever reason that database is „spezial“. I couldn’t say how, because all my sqlite commands via terminal or python work as they should.

I really appreciate the help.

Am 19.01.2015 um 22:41 schrieb Stephen Celis [email protected]:

Please provide as much information as possible if you want help troubleshooting, e.g.:

• The actual fatal error message you're getting
• A sample project (and/or playground) with the error intact
You're unfortunately not providing enough information to easily troubleshoot the issue.


Reply to this email directly or view it on GitHub.

from sqlite.swift.

ericcgu avatar ericcgu commented on June 18, 2024

This error message means there is a data issue, which has nothing to do
with SQLite.swift or Swift.

Look up "optionals"

On Mon, Jan 19, 2015 at 4:49 PM, thomasschoenfeld [email protected]
wrote:

the error reads:
fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)

here is the whole project (including the database).
https://dl.dropboxusercontent.com/u/107444970/Archiv.zip

If you think, everything is ok, then maybe for whatever reason that
database is „spezial“. I couldn’t say how, because all my sqlite commands
via terminal or python work as they should.

I really appreciate the help.

Am 19.01.2015 um 22:41 schrieb Stephen Celis [email protected]:

Please provide as much information as possible if you want help
troubleshooting, e.g.:

• The actual fatal error message you're getting
• A sample project (and/or playground) with the error intact
You're unfortunately not providing enough information to easily
troubleshoot the issue.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#41 (comment)
.

from sqlite.swift.

stephencelis avatar stephencelis commented on June 18, 2024

@thomasschoenfeld Please take the time to read the Swift book in iBooks. There are a lot of assumptions this code is making:

screen shot 2015-01-19 at 3 05 05 pm

And this line isn't even in SQLite.swift yet.

You're using ! to force-unwrap an optional. In this case, NSBundle.pathForResource can return nil if the resource doesn't exist. It's not finding CalendarCache.sqlite3 because the only bundle resource available is CalendarCache (you should add a suffix/extension to the resource). I also had 2 additional problems with your project because of how you packaged it, though it's probably not an issue for you in the moment:

  1. You didn't copy the CalendarCache resource into your project, so I had to manually re-add it.
  2. You didn't package the SQLite.swift directory with the project, so I had to manually re-add it.

I'd also recommend always looking at the line in question that you're having problems with, in this case the NSBundle.pathForResource line. Break it apart, debug every aspect of the statement, and read the Apple documentation:

func pathForResource(_ name: String?,
              ofType extension: String?) -> String?
Parameter Description
name The name of the resource file. If name is an empty string or nil, returns the first file encountered of the supplied type.
extension If extension is an empty string or nil, the extension is assumed not to exist and the file is the first file encountered that exactly matches name.
Return Value

The full pathname for the resource file or nil if the file could not be located.

There's more. There's a "discussion" section and it goes on to link to a specific section of the Bundle Programming Guide.

Sorry that I can't really help more than that. It's taken a long time to get to the point of realizing that the problems you're having are iOS/Mac/Xcode development issues and were unrelated to SQLite.swift.

from sqlite.swift.

thomasschoenfeld avatar thomasschoenfeld commented on June 18, 2024

mh, what exactly did you do when you say you „manually re-added“ them? I am not that familiar with Xcode and was under the impression, once dragged into Xcode (and with „copy if needed“ checked) that Xcode would handle everything behind the scenes, linke all sources / files etc.

I added the suffix. It started running but I got this error now…..
so far so good...
fatal error: unable to open database file: file /Users/thomasschonfeld/Desktop/Scripte/SwiftandSQlite/Test201501200820/Test201501200820/SQLite.swift-master/SQLite Common/Database.swift, line 335
Did you run „my database“ without issues after you „manually re-added“ the files? There is no designated resources folder within the project folder in finde so I simply copied everything in the project „root“ folder. That did not help. So that „manually re-added“ you did is probably not what I think it is.

After being stuck on this I finished all my desired sql command and startet coding in python and had no issue with that. I wonder, if I might be better of using python, pulling the data I need into an object and working from there with swift.

Am 20.01.2015 um 00:09 schrieb Stephen Celis <[email protected] mailto:[email protected]>:

@thomasschoenfeld Please take the time to read the Swift book in iBooks. There are a lot of assumptions this code is making:

This line isn't even in SQLite.swift yet.

You're using ! to force-unwrap an optional. In this case, NSBundle.pathForResource can return nil if the resource doesn't exist. It's not finding CalendarCache.sqlite3 because the only bundle resource available is CalendarCache (you should add a suffix to the resource). I also had 2 additional problems with your project because of how you packaged it, though it's probably not an issue for you in the moment:

• You didn't copy the CalendarCache resource into your project, so I had to manually re-add it.
• You didn't package the SQLite.swift directory with the project, so I had to manually re-add it.

Reply to this email directly or view it on GitHub.

Mit freundlichen Gruessen

Thomas Schönfeld
Technischer Leiter

Bestellen Sie unseren Newsletter!
Sie erhalten Einladungen zu unseren kostenlosen IT-Workshop und Infos zu exklusiven Angeboten:
http://www.kleinofen.de/newsletter-bestellen.php

Kurfürstenstrasse 10
D-40211 Düsseldorf
Telefon 0211 3552-208
Handy 0173 6058520
Telefax 0211 3552-199
Geschäftsführer: Richard Kleinofen
USt-Nr.: 133/5844/0440
USt-IdNr.: DE 121301230
Amtsgericht Düsseldorf, HRB 25060

from sqlite.swift.

stephencelis avatar stephencelis commented on June 18, 2024

mh, what exactly did you do when you say you „manually re-added“ them? I am not that familiar with Xcode and was under the impression, once dragged into Xcode (and with „copy if needed“ checked) that Xcode would handle everything behind the scenes, linke all sources / files etc.

Try downloading your "Archiv.zip" on another computer and running your project.

I added the suffix. It started running but I got this error now…..

so far so good...
fatal error: unable to open database file: file /Users/thomasschonfeld/Desktop/Scripte/SwiftandSQlite/Test201501200820/Test201501200820/SQLite.swift-master/SQLite Common/Database.swift, line 335

Did you run „my database“ without issues after you „manually re-added“ the files? There is no designated resources folder within the project folder in finde so I simply copied everything in the project „root“ folder. That did not help. So that „manually re-added“ you did is probably not what I think it is.

Well it appears there's a bug here or a missing implementation detail. Try removing readonly: true for the moment. I'll investigate what else is required to get SQLITE_OPEN_READONLY working.

Edit: You know what? I removed readonly: true, ran it once successfully, then added readonly: true back and it still ran just fine.

After being stuck on this I finished all my desired sql command and startet coding in python and had no issue with that. I wonder, if I might be better of using python, pulling the data I need into an object and working from there with swift.

I think you should work with what you're comfortable with or take the time to better learn Swift, Objective-C, Xcode, and Cocoa.

from sqlite.swift.

thomasschoenfeld avatar thomasschoenfeld commented on June 18, 2024

yeah, without readonly: true everything works fine. Well, and playground still does not.

Am 20.01.2015 um 18:57 schrieb Stephen Celis [email protected]:

mh, what exactly did you do when you say you „manually re-added“ them? I am not that familiar with Xcode and was under the impression, once dragged into Xcode (and with „copy if needed“ checked) that Xcode would handle everything behind the scenes, linke all sources / files etc.

Try downloading your "Archiv.zip" on another computer and running your project.

I added the suffix. It started running but I got this error now…..

so far so good...
fatal error: unable to open database file: file /Users/thomasschonfeld/Desktop/Scripte/SwiftandSQlite/Test201501200820/Test201501200820/SQLite.swift-master/SQLite Common/Database.swift, line 335
Did you run „my database“ without issues after you „manually re-added“ the files? There is no designated resources folder within the project folder in finde so I simply copied everything in the project „root“ folder. That did not help. So that „manually re-added“ you did is probably not what I think it is.

Well it appears there's a bug here or a missing implementation detail. Try removing readonly: true for the moment. I'll investigate what else is required to get SQLITE_OPEN_READONLY working.

After being stuck on this I finished all my desired sql command and startet coding in python and had no issue with that. I wonder, if I might be better of using python, pulling the data I need into an object and working from there with swift.

I think you should work with what you're comfortable with or take the time to better learn Swift, Objective-C, Xcode, and Cocoa.


Reply to this email directly or view it on GitHub.

from sqlite.swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.