Re: [sqlalchemy] Re: AuditLog/History logging

2010-11-04 Thread chaouche yacine
You can place triggers in your class definitions, there are decorators for this, see @afterUpdate, @beforeUpdate, @afterDelete, @beforeDelete, @afterInsert, @beforeInsert. You can search for these in the documentation, I am not sure of the exact spelling tho. Cheers, Y.chaouche -

[sqlalchemy] Assigning to a deferred column

2010-11-04 Thread Eoghan Murray
I have the following: objs = MyTable.query.options(defer(Table.potentially_very_long_str_column)).all() for obj in objs: obj.potentially_very_long_str_column = '' At the moment, I'm seeing the assignment in the loop issue the `SELECT potentially_very_long_str_column`, even

Re: [sqlalchemy] Assigning to a deferred column

2010-11-04 Thread Michael Bayer
is this a mutable type like PickleType? the previous value should not be loaded otherwise (assuming at least a recent 0.5 or 0.6 version). If so, the mutability flag should be disabled. On Nov 4, 2010, at 7:05 AM, Eoghan Murray wrote: I have the following: objs =

[sqlalchemy] Universal way to process inserting or updating values

2010-11-04 Thread Kent
We are writing an application that can run on PostgreSQL or Oracle. Since postgres treats NULL and '' (empty string) differently, while Oracle treats '' as NULL, this can cause subtle behavior differences based on the underlying database. Can you think of a way I could easily intercept all UPDATE

Re: [sqlalchemy] Universal way to process inserting or updating values

2010-11-04 Thread Michael Bayer
On Nov 4, 2010, at 11:16 AM, Kent wrote: We are writing an application that can run on PostgreSQL or Oracle. Since postgres treats NULL and '' (empty string) differently, while Oracle treats '' as NULL, this can cause subtle behavior differences based on the underlying database. Can you

Re: [sqlalchemy] Universal way to process inserting or updating values

2010-11-04 Thread Kent Bower
If I intercept strings that are empty and replace with None, is there potential problems because the database record and the python object are out of sync? Thereafter, will sqla believe the column value has changed and try to write again on next flush()? On 11/4/2010 11:42 AM, Michael

[sqlalchemy] Look for the best way to undelete a model

2010-11-04 Thread Mike Bernson
I have a transaction started with begin I then delete a record in the transaction. I then commit and the commit fails. I now want to continue by undelete the record but leave record in the session. I want to leave the record in the session because session is doing caching. The session is

Re: [sqlalchemy] Universal way to process inserting or updating values

2010-11-04 Thread Michael Bayer
On Nov 4, 2010, at 4:06 PM, Kent Bower wrote: If I intercept strings that are empty and replace with None, is there potential problems because the database record and the python object are out of sync? Thereafter, will sqla believe the column value has changed and try to write again on

Re: [sqlalchemy] Look for the best way to undelete a model

2010-11-04 Thread Michael Bayer
On Nov 4, 2010, at 4:38 PM, Mike Bernson wrote: I have a transaction started with begin I then delete a record in the transaction. I then commit and the commit fails. I now want to continue by undelete the record but leave record in the session. I want to leave the record in the session

Re: [sqlalchemy] Universal way to process inserting or updating values

2010-11-04 Thread Kent Bower
Actually, modifying the parameter in cursor_execute() for Postgres behaves exactly as Oracle does now in sqla without and proxy. sqla thinks it is writing an '' to the database, but Oracle is actually changing that to NULL, so it behaves the same. after and update to '', if you ask field is

Re: [sqlalchemy] Universal way to process inserting or updating values

2010-11-04 Thread Kent Bower
P.S. Thanks again very much -- 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,

[sqlalchemy] Creating tables in correct order

2010-11-04 Thread Richie Ward
I am trying to run this query: CREATE TABLE dependenciesbinary ( id INTEGER NOT NULL AUTO_INCREMENT, dependency_mn VARCHAR(128), name VARCHAR(128), operatingsystem VARCHAR(128), architecture VARCHAR(128), PRIMARY KEY (id), FOREIGN KEY(dependency_mn) REFERENCES

[sqlalchemy] Avoiding StaleDataError when updating Float values

2010-11-04 Thread Lenza McElrath
I am getting a StaleDataError when updating a Float column to the same value twice in a row. This happens because SQLAlchemy thinks that I am changing the value, but then the DB reports that no value was changed. Test case can be seen here: http://pastebin.com/vxFBAMxm Is there an easy way

[sqlalchemy] Re: Creating tables in correct order

2010-11-04 Thread Gunnlaugur Briem
Strictly that's not a query, it's a table definition. Do you mean that you are creating a declarative model class corresponding to this table definition? Posting your code would help more. You must define both tables on the same metadata instance (in declarative, that's typically done by having

Re: [sqlalchemy] Avoiding StaleDataError when updating Float values

2010-11-04 Thread Michael Bayer
On Nov 4, 2010, at 8:17 PM, Lenza McElrath wrote: I am getting a StaleDataError when updating a Float column to the same value twice in a row. This happens because SQLAlchemy thinks that I am changing the value, but then the DB reports that no value was changed. Test case can be seen

Re: [sqlalchemy] Avoiding StaleDataError when updating Float values

2010-11-04 Thread Lenza McElrath
Interesting. When I use your simple engine I do not get the error either, but I definitely get it when using my real configuration. We are using a connection pool. So the construction of the session maker for the test looks like this: e = sqlalchemy.create_engine('mysql://',