[Zope-DB] ZSQL Question - Insert multiple rows in one statement?

Sascha Gottfried s.gottfried at srz.de
Tue Aug 24 11:55:29 EDT 2010


Hi Mark,

it is best to do the looping in python. consider the python script as 
the proper place to process the form values taken from the request 
variable. No problem to invoke multiple zsql method calls from within 
this script. I even remember that all invoked zsql methods in one 
requests belong to a transaction. If one fails, a rollback is done. Your 
ZSQL connection has to be configured properly to use transactions and 
your server has to support them as well.

Just in case you do not already found this - latest zope book and the 
chapter about SQL connectivity
http://docs.zope.org/zope2/zope2book/RelationalDatabases.html

Am 24.08.2010 17:03, schrieb Mark Phillips:
> When I retrieve multiple values from a selection box, I need to create 
> a loop somewhere to insert the multiple values (rows) into a table. Is 
> there a way to do this within a ZSQL statement, or is it best to do 
> the looping in a Python script?
>
> My specific example....
>
> table 1 (Players) has information about players (i.e. team members for 
> a sports team). There is a primary key - playerID
> table 2 (Seasons) has information about each season - primary key is 
> seasonID
> table 3 (PlayerSeasons) has two columns - playerID and seasonID.
>
> The form to crud a player has a combobox where one can select multiple 
> seasons for a player. When I do an add or update, I have to add one or 
> more rows to the PlayerSeasons table. Does this loop have to be in a 
> Python script, or can it be implemented in ZSQL? I looked at the 
> 'multiple' keyword, but all the examples indicate that it apples to 
> sql tests, such as testing against a set of values. I can't seem to 
> find any examples where one is inserting multiple rows into a table.
>
> Thanks!
>
> Mark
>
>
> _______________________________________________
> Zope-DB mailing list
> Zope-DB at zope.org
> https://mail.zope.org/mailman/listinfo/zope-db
>
>
>
> __________ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version 5393 (20100824) __________
>
> E-Mail wurde geprüft mit ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>    




__________ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version 5393 (20100824) __________

E-Mail wurde geprüft mit ESET NOD32 Antivirus.

http://www.eset.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope-db/attachments/20100824/5dcd37b0/attachment.html 


More information about the Zope-DB mailing list