[Zope-DB] modifications on a query

Graziella Toutoungis graztoutoungis at yahoo.fr
Fri Jan 26 08:17:03 EST 2007


in my database i want to create a table1 who is the
result of a query on table2 and table3 like select
x2,y2,x3,y3 from table2 and table3...
-i want now to create the table1.
-evrey time the user try to insert into table1, i must
insert this data in the original table and verify the
possibility of the insertion.

my code now return a list of column name's like
['id', 'title','phon',...]
i want to create table1 from this list, i don't know
how i can do it, my code is:

 query ="SELECT id, name, value, shipping FROM
customer, invoice, orderinfo WHERE customer.id =
invoice.customer_id            AND
invoice.order_id=orderinfo.order_id;"
    
    print query

    curs.execute(query)
    
    names= [f[0] for f in curs.description]
    print 'names%s' %names
    tableColumn = []
    for name in names:
        tableColumn.append(name)
   

    value = []
    for row in curs.fetchall():
        for pair in zip(row):
            value.append(pair)
            print '%s' %pair
        print
        
    print value
    
    i = 0
    column=[]
   
    for x in tableColumn:
            test = tableColumn[i].strip()
            i += 1
            print test
            column.append(test)
    print column
                     
        
    
#    createQuery = 'CREATE TABLE test_fetch
%s'%tableColumn
#    print createQuery
    
    curs.execute("DROP TABLE test_fetch")
#    curs.execute(createQuery)

i will integrate in zope this code to create a form in
order to give the users the capability to manage my
database. 

any suggestions?

--- Maciej Wisniowski
<maciej.wisniowski at coig.katowice.pl> a écrit :

> 
> > I use zope2.9.4 with postgresql8.1, in my database
> i have some tables
> > are the result  of a query on other tables.
> > exe: table1 is the result of table2 with table3
> >
> > My user can connect to the database and he can
> modify the  table1,
> > this modification should done on the orginals
> tables table2 and table3
> >  my  problem is how  i can  specify the origin of
> the column in table
> > for verifing that table2 and table3 may this
> modifications?
> >
> > thanks for all suggetions.
> Is table1 a view?
> What does 'table2 with table3' mean?
> If you have SQL statement like:
> 
> select col1, col2, col3 from ....
> 
> then you know where columns come from... don't you?
> 
> -- 
> Maciej Wisniowski
> 



	

	
		
___________________________________________________________________________ 
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses 
http://fr.answers.yahoo.com


More information about the Zope-DB mailing list