[wxpython-users] App does not close down - py2exe - work around

Werner F. Bruhin werner.bruhin at free.fr
Wed May 28 07:04:39 PDT 2008


Hi Andrea,

Andrea Gavana wrote:
> Hi Werner,
>
> On Wed, May 28, 2008 at 9:39 AM, Werner F. Bruhin wrote:
>   
>> Hi Andrea,
>>
>> Andrea Gavana wrote:
>>     
>>> Hi Werner,
>>>
>>> On Wed, May 28, 2008 at 8:41 AM, Werner F. Bruhin wrote:
>>>
>>>       
>>>> Just an update in case anyone else runs into this.
>>>>
>>>> The problem seems to come from sqlalchemy, but I am not yet sure how to
>>>> resolved it nicely, but in the mean time I am using the following work
>>>> around.
>>>>
>>>> self.engine = db.sa.create_engine(dburl, encoding='utf8', echo=False)
>>>> self.Session = db.sao.sessionmaker(autoflush=True, transactional=True)
>>>> self.Session.configure(bind=self.engine)
>>>> self.ds = self.Session()
>>>> ...
>>>> self.ds.Close()
>>>>
>>>> # adding the following allows the app to close down correctly
>>>> del self.ds
>>>> del self.Session
>>>> del self.engine
>>>>
>>>>
>>>> Mentioned it on the SA list, but had no feedback yet.
>>>>
>>>>         
>>> I am using SQLAlchemy as well in one of my apps,
>>>       
>> What version of SA are you using?  I am currently on 0.4.3, but I hope that
>> 0.5 will be out before I am ready to release my new version.  If I read the
>> doc for 0.5 I see that some Session related stuff is changed/clean-up, so
>> maybe the problem is already dealt with in 0.5 (will try it as soon as an
>> alpha or beta version is available).
>>     
>
> After a migration from 0.3.4 (which has been a PITA), I am now using
> 0.4.6. There have been so many changes between 0.3 and 0.4 that I am
> still looking for possible bugs in my application because of that. Not
> to mention what has been done on the (once) useful and friendly
> select() statement.
>   
While I like SA it has taken me a lot longer to change over to it then I 
initially thought.   If there wouldn't be Michael Bayer I might have 
given up some time ago.  I switched to be more independent of db backend 
and as I would also like to do a TurboGears app based on the same db 
schema and as the other ORM didn't support Unicode as nicely as SA does.

...
> Uhm, then I am not sure what it could be. As we are using more or less
> the same SQLAlchemy configuration, I suspect there is something
> different with the binding to Firebird, as SQLite is not affected in
> any way. BTW, a completely off-topic question, is there any advantage
> in using Firebird instead of SQLite? 
Haven't looked at SQLite, but one of the reasons I did not go with it is 
that it is not enforcing relations integrity.  I am also not sure if you 
can created indexes.

A couple of links which might help.

http://en.wikipedia.org/wiki/Comparison_of_relational_database_management_systems
http://en.wikipedia.org/wiki/Firebird_(database_server)
> I am no expert in databases
> things, I was just curious to know if there is something I could do to
> speed up the initial loading of my database, which contains hundreds
> of simulation files ordered in a tree-like structure.
>   
I am no expert either, but here a couple of things I would look at:

- create indexes for your order-by clause(s) which are used often
- do you need to get all rows/records or can you only get what the user 
actually is looking for?  I got a table with grape varieties which I 
show in a virtual listctrl, it has  over 16,000 rows and it loads very 
quickly (subsecond).  I do a fetchall to get all the primary keys and 
then the virtual list only requests the records it really wants/needs to 
display and I keep the data for about 3 or 4 display pages in a cache 
(to handle the case where the user pages up and down).

PostgreSQL might also be a good option to check out - when I started 
there MS support was not great, but I think that has changed.

Werner


More information about the wxpython-users mailing list