Dynamic Update SQLs like in Delphi
Hello ! In Delphi I have a my own created mechanism what help me to do less code/error, and more performance in database/dataset handling. The technology is that: 1./ When I open a table with TDataSet.Open method, then it was generate updatesql array, and updatesql components. 2./ It is cache the modifications. 3./ In apply it is process the cache, and rewrite modifications in RW transaction. It is same with TClientDataSet class, but enhanced. When I was write an site in php, I rewrite this mechanism in php, and it is working good. Ok, but in this time I want to port it to Zope. In the 1./ the code is like this: a.) Get table name from SQL b.) Get the pyhisical fields of the table -> filter (omit) the another table fields, exmp: joined/grouped/etc. c.) Get a key fields from parameter, or the first field. d.) Generate SQL for INS/DEL/UPD e.) Store it In Zope I don't see any possibility to I create on-fly statements. My mechanism is good, because in my database I have 200 tables, and if I want to create all zsql method to all table, then I must write 200*3 update sql statement, and 200*1 select by id sql statement. And I don't say about the special selects - my way is handle all of these statements. So there are the ways I see to do it: 1./ I write it by hand. Many time,.... :-((((((((((((( 2./ I write an xml section creator in py. I create din. sqls in python+xml, and I insert into exported zope site file. Then I import it to zope. 3./ I write an subsite, what load all table descriptors to arrays, and create the zsql methods into zope site's folder. When the database content (structure) is changed, I recreate all zsql method. 4./ I access the zsql-s on-fly, and when it is must change (the table structure is changed) then I change the zsql method. But I don't know, what is happening, when another zope request thread is working with this method... 5./ I access the DA object, and can create dynamic SQL-s. But I can do that ???? 6./ I change the zope to the mod_python. (I don't want to do it, only if I haven't any solution) 7./ I am going to Antarctis, or to the Moon. Or to insane... 1/2/3 solutions are very ugly things, because the many zsql method is many text, and the zope fs is grow to very large. And when I forget to recreate this methods, the site is unavailable. Please help me: what I can do ? Thanx for any advance. -- Best regards, fowlertrainer mailto:fowlertrainer@anonym.hu
5./ I access the DA object, and can create dynamic SQL-s. But I can do that ????
Yes, sure. You just create the ZSQL Methods on the fly, and never store them in the ZODB. That way they will be unique to your thread, and you don't have to update the ZODB with every request. I'm not a big ZSQL expert, but I can't see any reason why that wouldn't work.
6./ I change the zope to the mod_python. (I don't want to do it, only if I haven't any solution)
Everythong you can do in mod_python, you can do in Zope. //Lennart+
Hello Lennart, Wednesday, December 10, 2003, 11:08:26 AM, you wrote:
5./ I access the DA object, and can create dynamic SQL-s. But I can do that ????
LR> Yes, sure. You just create the ZSQL Methods on the fly, and never store them LR> in the ZODB. That way they will be unique to your thread, and you don't have LR> to update the ZODB with every request. LR> I'm not a big ZSQL expert, but I can't see any reason why that wouldn't LR> work. Great idea - but how ? Anyone create a ZSQL method on-fly ? How to do it ? Thanx for any help !
From: <fowlertrainer@anonym.hu>
Great idea - but how ?
Anyone create a ZSQL method on-fly ?
No, I never have, but after a quick look at the code it looks like this should work: from Shared.DC.ZRDB.DA import DA sql = DA('id', '', 'id_of_the_database_connection', 'the sql arguments', 'the sql code') result_records = sql(parameters=likethis) It's worth a try. //Lennart
fowlertrainer@anonym.hu wrote at 2003-12-10 09:09 +0100:
In Delphi I have a my own created mechanism what help me to do less code/error, and more performance in database/dataset handling.
You should probably have a look at "ZSQLnolkWizzard" (a third party Zope product to generate insert/update/report forms for tables found in a database). -- Dieter
participants (3)
-
Dieter Maurer -
fowlertrainer@anonym.hu -
Lennart Regebro