On Sun, Dec 26, 2010 at 11:16 AM, Noah Hall <enali...@gmail.com> wrote: > As a rule, I tend to open and close a connection based on what I'm doing > with the database.
I +1 that. Usually if I open the db in a function, I commit and close. If it's in an app, for me personally, that should be the only place it takes place. So insert into, or call from would seem more likely functions to retrieve in a certain situation, like opening a project file would open the project db file, load the info, and then commit/close. Then saving would open commit/close the required info. If I were to directly run a series of queries one after > another, I would keep it open until a change in interface (referring to > changes in objects, both masters and slaves). > Also, you can perform any query that does not change any records safely > without a commit, for example, searches. For everything else, you need to > call commit - but you don't need to close the connection. Nor open one, if it's not necessary. Load the info on file open, do what the user does, then save through open close. Unless intermittent saves are necessary within the app loop. > _______________________________________________ > Tutor maillist - tu...@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- They're installing the breathalyzer on my email account next week. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor