Hi all

I'm pretty new to web2py and web development in general. I'm really stuck 
with something and haven't been able to find a tutorial which can help me 
out etc. I was wondering if some one could point me in the right direction. 

I have three tables. I want to upload a csv, and update each table in 
sequence, so a newly generated primary key  can be passed to each 
successive table. 

(1)
db.define_table('study_info',                      
                Field('title'))
                                                                     One to 
many relationship
(2)
db.define_table('core_data',                                                
        
                Field('study_info_id', 'reference study_info'),
                Field('taxon_name', type = 'string', 
comment='Classification of sample collected'))

(3)
db.define_table('sample_data',                                           
 One to many relationship
                Field('Core_data_ID', 'reference'),
                Field('value', type = 'double'))


So just to clarify , data gets entered into the first table,  the primary 
key from table 1 is then passed to the foreign key of 2, then same again 
for 2 to 3. 

I managed to the function working to update one table from a csv, but tried 
a few things out from there but nothing worked. Would i somehow modify this 
using a for loop?

def import_csv(): 
    from gluon.sqlhtml import form_factory
    form = SQLFORM.factory(Field('csvfile','upload',uploadfield=False))
    if form.process().accepted:
        db.study_info.import_from_csv_file(request.vars.csvfile.file)
        redirect(URL('index'))
    return dict(form=form) 


Thanks in advance

Matt

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to