Re: [Pyobjc-dev] SQLite and PyObjC
Brought to you by:
ronaldoussoren
|
From: David B. <db3...@gm...> - 2008-07-07 19:48:10
|
John Velman <ve...@co...> writes: > 1. Which is better to use for the sqlite interface, the Xcode interface to > sqlite, or the Python interface? If Xcode is better, how the heck can I > find some documentation? Googling or searching in the developer > documentation hasn't gotten me there yet. Probably because I don't know > the right search words. The amount of Apple documentation is enormous. Personally I use SQLAlchemy with a sqlite back-end - e.g., stay completely on the Python side of the equation for data management. For my application I didn't need any of the ORM features, so I'm just using the SQL generation layer of SQLAlchemy, but it's great for that. > 2. For display of tabular query results, is NSTableView the "best" way to > go? I've had a quick scan of the "Understanding the NSTableView Class, > and a look at one of the examples, and I'm overwhelmed. I don't need to > edit this in place. One alternative would appear to be formatting into > columns in Python, and use some form of NSBrowser or NSTextView. NSTableView is definitely my workhorse for presenting tabular information, even if only a single column. You just get too much behavior for free not to use it IMO. In terms of controlling the data flow, I've actually used multiple methods: First, I started out enamoured with data bindings, and used them a lot, even for an array source to a data controller driving an NSTableView. Re-assigning the entire array (to trigger the automatic PyObjC binding update) was sometimes a pain, particularly when I had other state in the array I wanted to keep, so in some cases I started controlling the notification myself, permitting mutation in place of the data - e.g., I called willChangeValueForKey_, then modified, then called didChangeValueForKey_). But as I went on, I found that although there was slightly more setup, creating an appropriate data source for the NSTableView was more flexible, particularly as the data changed, or if it was being retrieved incrementally, such as from the network or database. I still have a mixture of approaches in the main application I used this with, but if I were starting over, I'd probably use bindings for simple text fields and status information, but stick with data sources for the major table views. -- David |