If you can make the field names in the DAL model match exactly, you can 
simply do:

db.mytable.insert(**db.mytable._filter_fields(record_dict))

If you can't change the field names in the database itself but are 
comfortable changing the names within your DAL models, you can use the 
"rname" option when defining the fields that have mismatched names:

Field('tax', rname='sales_tax')

The above would allow you to do inserts using the name "tax", even though 
the real field name in the database is "sales_tax".

Otherwise, I suppose you would just do something like:

db.mytable.insert(field1=record['field1'], field2=record[
'field2_alt_spelling'], ...)

Anthony

On Wednesday, January 10, 2018 at 7:48:33 AM UTC-5, Rahul wrote:
>
> Hi All, Massimo
>      I am receiving a dictionary of records from a webservice like below 
> (sample single record with just a few fields here) . Now I want to parse 
> all the records and insert the data in my table (Currently SQLite and later 
> it would be POSTGRE) . What is the best way to insert data into SQLite or 
> other databases using DAL from following code. I am assuming that since we 
> would utilize DAL it  might work irrespective of underlying DB. my table 
> has similar fields but fieldnames and their order is changed a bit. 
> {u'status': None, u'tax': 3.6, u'entity': u'payment', u'currency': u'INR', 
> u'id': u'128934802340', }
>
>
> Thanks in advance for all the help,  :-) 
>
> Rahul
>
>
>
>
>
>

-- 
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