On Apr 25, 10:48 am, Dan F <[email protected]> wrote:
[...]
> Does the web2py DAL allow batch updates etc. to occur without recourse
> to actual SQL statements?  i.e., updating all columns in the database
> without making a call per record?  If not, functionality like this gives
> SQLAlchemy perhaps another benefit.

If I understand the statement: yes we can. for example say I have a
table "mytable" with a field1 and a field2 and I want to update every
record that has field1==0 and set its value to the value of field1+2
and the value of field3 to 0.

db(db.mytable.field1==0).update(field1=db.mytable.field2+2, field3=0)

You can have complex conditions and update more columns in the same
statement.

Anyway this thread nailed a major difference between SQLAlchemy and
web2py. SQLAlchemy gives you more freedom than web2py (because web2py
forces all records to have a autoincrement ID). If this is important
for you use SQLAlchemy. This does not mean that in web2py you cannot
handle tables that have other constraints (as long as they also have
the auto increment ID). web2py can also handle very complex
constraints that cannot even be declared in SQL at the framework level
using validators that talk to the database.

Personally I believe that designing a database schema that does not
have a autoincrement ID is a mistake and this is why web2py enforces
it. This buys us a lot of other goodies that other ORMs do not have.
For example automatic forms and the ability to assign uuids to records
for import/export/merge of databases (web2py can export an entire
database in Oracle and reimport it on MSSQL or Google App Engine
without breaking references even if the autoincrement IDs of the
source and destination may be different).

Anyway, I am not comfortable with talking about web2py on this list.
As I said I very much like TG and its developers. But if you ask me
questions I feel compelled to answer.

Massimo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to