-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi.
I have the following use case: a table that contains the layout info of some elements in a web page. The layout is fixed, that is, the number and the positions of the elements that can be displayed is fixed. This means that in order to change the layout I will have to update this table. But for the very first elements, I need to insert the first values. I wrote this function: http://paste.pocoo.org/show/186666/ It first executes the supplied UPDATE statement, and if no rows are returned, it try to convert it to on INSERT statement and execute it. A better solution is to use the SQL:2003 MERGE statement, but it is not supported by PostgreSQL. The function I wrote is very limited, but I would like to know if the implementation is at least correct. I would also like to know if there is a better (and portable at least on PostgreSQL) pattern. MySQL has the REPLACE statement, but the logic is different from the one I need; it first try to INSERT and then to UPDATE. Thanks Manlio -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkuTzP0ACgkQscQJ24LbaUR/CACfQNLWLv9rMN5udPY+POC1FeyC cuwAnRqUKt/uCfbWroEsGYoOsVzEwK3D =YF0U -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.