Re: Yet another database question, please



nmp a écrit :
Bruno Desthuilliers wrote:

nmp a écrit :
Hello to all. I am only just learning both Python and PyGTK (with
Glade). I also need to learn how to use databases in my programs. My
preliminary research leads me in the direction of SQLAlchemy, which
seems to be what everybody else is using.

Since it's not quite clear from your question: SQLAlchemy is a pretty
good package, but you need still need to know SQL to use it effectively
(if it's your case, please forget this remark).

I will forget the remark then ;)

Sorry, was not obvious from your question !-)

(snip)
So, does anyone have a good example that shows how to tie these things
toegether? I would like to have the GUI dialogs and treeviews directly
interacting with the underlying tables and/or views.

[cough]Like Borland Delphi 1.0, in the nineties...[/cough]
From experience (with Delphi, VB and a couple related but less known
systems), directly tying widgets to database is a pretty brittle
architecture for anything else than Q&D Simple Stupid GUI/DB pipelines.

Well, that's one of the reasons I mentioned Delphi within a cough... I remember using that some years ago for precisely the quick and dirty hacks that you speak of. I am sure there are better ways, but can you please point me to them?

Well... I'm afraid I never done any serious rich-client programming in Python - I'm mostly doing web and sysadmin related stuff nowadays (that is, for the or more past years). I just know that when I was doing rich-client business apps on Window (that is: in a former life...), I always ended up removing all those pesky "db-widgets" and manually writing the code to tie GUI and model together - I guess that's what is called a "controler" in the MVC triad ?-)

(snip)

Of course I would like a very robust solution, this is very important. However, fast and relatively "easy" development and prototyping are important too. Python was "sold" to me as a language that is very ceonvenient for this.

Yeps, that's how they got me hooked too !-)

(snip)

Accessing databases seems to be a bigger step though. There doesn't seem to be a standardised way to do it. And I am slightly nervous about having to reinvent any wheels.

About DB access, there are two major APIs : the official (low-level - that is,relatively to the other one...) db-api, and the higher-level SQLAlchemy package. Note that while having an ORM part, SQLAlchemy is first an higher-level SQL/Python integration layer, so you can still think "relational" - but with something much more powerful than strings to build your queries.

Tying the model (wether relational or not) with the UI is quite a different problem. I assume you know what MVC mean, and from then I'm afraid I can't help more.

.



Relevant Pages

  • Re: A question on decorators
    ... some of the databases and tables I access are being accessed by other ... SQLAlchemy or SQLObject, because I didn't want too (although in the ... the OP is looking for the PersistentDict and PersistentList   ... Python module would have to allocate from the ROM, ...
    (comp.lang.python)
  • Re: A question on decorators
    ... some of the databases and tables I access are being accessed by other ... SQLAlchemy or SQLObject, because I didn't want too (although in the ... I'm not sure that triggering a database write for each and every modified attribute is a good thing; I'd use a "dirty" flag instead and write all modifications at the end. ... Since not all methods modify the object contents, using a metaclass to flag all of them isn't a good idea either. ...
    (comp.lang.python)
  • Re: Yet another database question, please
    ... I also need to learn how to use databases in my programs. ... My preliminary research leads me in the direction of SQLAlchemy, which seems to be what everybody else is using. ... Since it's not quite clear from your question: SQLAlchemy is a pretty good package, but you need still need to know SQL to use it effectively. ... Like Borland Delphi 1.0, in the nineties... ...
    (comp.lang.python)