[sqlalchemy] Re: sqlalchemy object serialization / deserialization

2007-12-21 Thread Lele Gaifax
On Thu, 20 Dec 2007 20:45:46 -0500 Rick Morrison [EMAIL PROTECTED] wrote: Re-implementing pickle with a JSON storage format is going to be a huge job, and really won't give you anything that you don't already get from pickle That's surely right: consider that Pickle is not simply a format,

[sqlalchemy] Readonly objects/protecting objects from modifications

2007-12-21 Thread Andreas Jung
Is there a way to protect objects from modifications? I have a complex self-referential data structure that is passed to some other modules written by co-workers. I need to avoid that the data structure is changed (because of programming errors). Is there an easy way to accomplish this (other

[sqlalchemy] Re: Default data and table related database objects

2007-12-21 Thread Michael Bayer
On Dec 21, 9:48 am, simpsomboy [EMAIL PROTECTED] wrote: I need to create some database objects(like a trigger) and insert some initial data into table after creation, so I need to know if have some way to do it transparent on sqlalchemy database trigger syntax is pretty database specific

[sqlalchemy] Default data and table related database objects

2007-12-21 Thread simpsomboy
Hello all, I've done some finds over list, but not found the answer to solve my problem. I need to create some database objects(like a trigger) and insert some initial data into table after creation, so I need to know if have some way to do it transparent on sqlalchemy, like putting a method on

[sqlalchemy] count() does not seem to work correctly with relationships

2007-12-21 Thread Justin
DB = sqlite I don't now if this is a bug or an issue with my mapper config, but the count() method does not work correctly through relationships. Given this mapper: mapper(Branch, branches, properties={ 'reports':dynamic_loader(Report, backref='branch') }) b = sess.query(Branch).first()

[sqlalchemy] Re: Default data and table related database objects

2007-12-21 Thread Michael Bayer
On Dec 21, 2007, at 11:09 AM, Alexandre da Silva wrote: it would be just a Method like after_create_execute(SOME DATABASE SPECIFIC SQL), and this method should be called after creation of table, but just on creation... would be usefull have an before_drop_execute(SOME STATEMENT) to make

[sqlalchemy] Re: Default data and table related database objects

2007-12-21 Thread Alexandre da Silva
database trigger syntax is pretty database specific so we dont have a generic DDL construct for that right now. you can issue the DDL using a textual execute like engine.execute(CREATE TRIGGER ...). for inserting of data you usually would use a table.insert() construct. ok, it helps if I

[sqlalchemy] Re: Default data and table related database objects

2007-12-21 Thread Alexandre da Silva
we have a ticket in the works for this: http://www.sqlalchemy.org/trac/ticket/903 ok, I will look at this ticket. note that this feature applies to Table objects, not ORM mapped classes. A central tenet of SQLAlchemy is that the object relational mapper is an optional package which

[sqlalchemy] SchemaGenerator.get_column_default_string

2007-12-21 Thread Christophe de VIENNE
Hi all, In the HEAD version, the table creation does not set the default values on the columns (tested on mysql and mssql) It seems that the function SchemaGenerator.get_column_default_string (in compiler.py) always returns None, even if a default value is specified. 801 def

[sqlalchemy] Re: SchemaGenerator.get_column_default_string

2007-12-21 Thread Michael Bayer
On Dec 21, 2007, at 11:57 AM, Christophe de VIENNE wrote: Hi all, In the HEAD version, the table creation does not set the default values on the columns (tested on mysql and mssql) It seems that the function SchemaGenerator.get_column_default_string (in compiler.py) always returns None,

[sqlalchemy] compoundprimary key

2007-12-21 Thread Lukasz Szybalski
Hello, What is the code for setting up a compound key? For normal key I would do: Column('id', Integer, primary_key=True, autoincrement), For compound key I do? Column('id', Integer, primary_key=True), Column('idupdate', Integer, primary_key=True, autoincrement), In sql form that would be

[sqlalchemy] Re: SchemaGenerator.get_column_default_string

2007-12-21 Thread Christophe de VIENNE
2007/12/21, Michael Bayer [EMAIL PROTECTED]: In the HEAD version, the table creation does not set the default values on the columns (tested on mysql and mssql) It seems that the function SchemaGenerator.get_column_default_string (in compiler.py) always returns None, even if a default

[sqlalchemy] Re: Readonly objects/protecting objects from modifications

2007-12-21 Thread Rick Morrison
Something like this is available on a roll-your-own basis via Python properties along with some mapper tricks: http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_mapper_overriding I would be +1 for such a feature implemented on mapped instances, could be useful for detecting those

[sqlalchemy] Re: Caching

2007-12-21 Thread Anton V. Belyaev
I rearranged instance-level deferred loaders to be serializable instances in r3968. you can now pickle an instance + its _state and restore, and all deferred/lazy loaders will be restored as well. I didnt yet test it specifically with merge() but give it a try, you shoudnt be getting that

[sqlalchemy] Re: Readonly objects/protecting objects from modifications

2007-12-21 Thread sdobrev
i have such thing implemented externaly but it is definitely not nice (read: tricky and underground) - replacing the __dict__ with something handmade that does what i say as i say if i say. that's dbcook's reflector for my static_type structures; look in dbcook/usage/static_type if interested.

[sqlalchemy] Re: sqlalchemy_types names consistency

2007-12-21 Thread Michael Bayer
On Dec 21, 2007, at 2:20 PM, Lukasz Szybalski wrote: http://www.sqlalchemy.org/docs/04/sqlalchemy_types.html Is there a reason why I can define my column with Integer or INTEGER but not Decimal,Text,Blob etc. Shouldn't there be some kind of consistency? Either Capitalized letters or

[sqlalchemy] Re: Readonly objects/protecting objects from modifications

2007-12-21 Thread Michael Bayer
On Dec 21, 2007, at 3:13 PM, Rick Morrison wrote: Something like this is available on a roll-your-own basis via Python properties along with some mapper tricks: http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_mapper_overriding I would be +1 for such a feature

[sqlalchemy] Re: SchemaGenerator.get_column_default_string

2007-12-21 Thread Michael Bayer
On Dec 21, 2007, at 2:10 PM, Christophe de VIENNE wrote: 2007/12/21, Michael Bayer [EMAIL PROTECTED]: In the HEAD version, the table creation does not set the default values on the columns (tested on mysql and mssql) It seems that the function SchemaGenerator.get_column_default_string (in

[sqlalchemy] Re: Caching

2007-12-21 Thread Michael Bayer
On Dec 21, 2007, at 3:54 PM, Anton V. Belyaev wrote: 1) I created an object with deferred property (not None). 2) Reloaded it in a new session (to erase deferred property) 3) Pickled/Unpickled 4) Removed everything but properties and _state. what did you remove exactly ? there are some

[sqlalchemy] Re: Caching

2007-12-21 Thread Michael Bayer
On Dec 21, 2007, at 3:54 PM, Anton V. Belyaev wrote: merge worked without an exception this time. merge is working rudimentally for objects with unloaded scalar/ instance/collection attributes in r3974. whats not yet happening is the merging of the various query.options() that may be

[sqlalchemy] get mapped class

2007-12-21 Thread Alexandre da Silva
Hello Again, I am already trying go get the list of mapped tables. I currently got a list from sqlalchemy.org.mapper from the weakref mapper_registry, but I don't know if that values are useful for my context. I also have another question, I have some way to access the mapped class from the

[sqlalchemy] Mapper properties and a callback

2007-12-21 Thread Dave Harrison
Hi all, I have a situation where I want to declare a relation between two tables, but I want to be able to run a callback whenever I append to that relation. Here's an example class Kennel: def callback(self, o): print callback, o mapper = Mapper( Kennel, kennelTable,

[sqlalchemy] SQLALchemy used at gcollab

2007-12-21 Thread Sanjay
Hi All, We have just released www.gcollab.com, a site hosting global collaborative services such as tmail. SQLAlchemy is being used as the database component/ORM of gcollab. My experience with SQLAlchemy has been rewarding and smooth. The documentation is great. The support and response in this