db.country.insert(**row)

this works for every function in Python: with ** you can pass named
arguments from a dictionary.

On 27 Apr, 08:25, David Zejda <[email protected]> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> There is a table:
>
> db.define_table('country',
>     SQLField('code'),
>     SQLField('name'))
>
> I know, I can do:
>
> db.country.insert(code="UK", name="United Kingdom")
>
> But I have values to be inserted in a dictionary:
>
> row = { "code":"UK", "name":"United Kingdom" }
>
> I would like to do it in a general way:
>
> db.country.insert(row)
>
> Or so. Is it possible somehow?
>
> Thank you!
> David
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org
>
> iEYEARECAAYFAkn1skoACgkQ3oCkkciamVH7cQCfbJNDypx0+UDlEHWcKOt4EVDe
> XZEAn0zlhLrdyZ+0uNwLKpg+4wNPYBuS
> =i4qG
> -----END PGP SIGNATURE-----
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to