Yet another database question, please
Bruno Desthuilliers
bruno.42.desthuilliers at wtf.websiteburo.oops.com
Fri Nov 30 11:05:41 EST 2007
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.
More information about the Python-list
mailing list