[sqlalchemy] sa0.5 __init__ replacement

2008-06-29 Thread az
hi i have class X(object): X.__init__ = setattr_kargs where def setattr_kargs( *args, **kargs): assert len(args)==1 x = args[0] for k,v in kargs.iteritems(): setattr( x, k, v) when SA comes to play, it fails to find a 'self' in __init__ arguments. in format_argspec_plus(),

[sqlalchemy] Re: validation and old values

2008-06-29 Thread sandro dentella
thanks sandro *:-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED]

[sqlalchemy] session expire and discard

2008-06-29 Thread sandro dentella
Hi, is there a way to say to a session to forget all the changes to an object without hitting the database. Expire or refresh do that but at the prize of a new select. Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

[sqlalchemy] register dml to be triggerred after create_all

2008-06-29 Thread alex bodnaru
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 hi friends, i wish to insert some initial data in a few management tables (like applications groups, roles etc). is there a way to register dml to be done after create_all ends? i'd specifically like it to happen after the entire ddl dust reaches

[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-29 Thread Michael Bayer
to my knowledge MySQL doesn't support DEFAULT on date/time columns. You can work with the MySQL database directly a little bit to confirm this. On Jun 28, 2008, at 3:18 PM, Gloria W wrote: Hi All, Looking back in these posts, I tried several older variants of MySQL datetime column

[sqlalchemy] Re: session expire and discard

2008-06-29 Thread Michael Bayer
On Jun 29, 2008, at 11:23 AM, sandro dentella wrote: Hi, is there a way to say to a session to forget all the changes to an object without hitting the database. Expire or refresh do that but at the prize of a new select. there is not because for it to be generally useful, it needs to

[sqlalchemy] Re: register dml to be triggerred after create_all

2008-06-29 Thread jason kirtland
alex bodnaru wrote: hi friends, i wish to insert some initial data in a few management tables (like applications groups, roles etc). is there a way to register dml to be done after create_all ends? i'd specifically like it to happen after the entire ddl dust reaches the ground.

[sqlalchemy] Implementation patterns for initializing the model and obtaining the mappers

2008-06-29 Thread Andreas Jung
I am coming from the Zope world and implemented a SA integration layer z3c.sqlalchemy. It basically provides a 'wrapper' exposing a thread-local session as property and as a registry for mappers that can be accessed through a getMapper(mapper_name) method. Now with the declarative layer I am

[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-29 Thread jason kirtland
Gloria W wrote: Hi All, Looking back in these posts, I tried several older variants of MySQL datetime column initialization discussed here, and they're not working. This works in Postgresql: sqlalchemy.Column('date_created', sqlalchemy.DateTime,

[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-29 Thread jason kirtland
jason kirtland wrote: Gloria W wrote: Hi All, Looking back in these posts, I tried several older variants of MySQL datetime column initialization discussed here, and they're not working. This works in Postgresql: sqlalchemy.Column('date_created', sqlalchemy.DateTime,

[sqlalchemy] Re: sa0.5 __init__ replacement

2008-06-29 Thread jason kirtland
[EMAIL PROTECTED] wrote: hi i have class X(object): X.__init__ = setattr_kargs where def setattr_kargs( *args, **kargs): assert len(args)==1 x = args[0] for k,v in kargs.iteritems(): setattr( x, k, v) when SA comes to play, it fails to find a 'self' in

[sqlalchemy] Re: Implementation patterns for initializing the model and obtaining the mappers

2008-06-29 Thread Michael Bayer
On Jun 29, 2008, at 12:46 PM, Andreas Jung wrote: This approach is ugly (because of putting the mapper within the local scope into the global scope (in order to make them importable) and because of this code within main.py: import model model.setup(dsn) from model import MyMapper,

[sqlalchemy] Re: register dml to be triggerred after create_all

2008-06-29 Thread alex bodnaru
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 thanks a lot jason, now i see the metadata version of the same. alex jason kirtland wrote: | alex bodnaru wrote: | hi friends, | | i wish to insert some initial data in a few management tables (like applications | groups, roles etc). | | is there

[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-29 Thread Gloria W
This gives me an error: sqlalchemy.Column('date_created', mysql.MSTimeStamp, sqlalchemy.PassiveDefault(text(CURRENT_TIMESTAMP)), nullable=False)) NameError: global name 'text' is not defined --~--~-~--~~~---~--~~ You received this message because you are

[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-29 Thread jason kirtland
Gloria W wrote: This gives me an error: sqlalchemy.Column('date_created', mysql.MSTimeStamp, sqlalchemy.PassiveDefault(text(CURRENT_TIMESTAMP)), nullable=False)) NameError: global name 'text' is not defined from sqlalchemy import text

[sqlalchemy] Re: Implementation patterns for initializing the model and obtaining the mappers

2008-06-29 Thread Andreas Jung
--On 29. Juni 2008 16:57:16 -0400 Michael Bayer [EMAIL PROTECTED] wrote: On Jun 29, 2008, at 12:46 PM, Andreas Jung wrote: This approach is ugly (because of putting the mapper within the local scope into the global scope (in order to make them importable) and because of this code within

[sqlalchemy] Columns division: cast() doen't seem to work. Or how to use it ?

2008-06-29 Thread Dominique
Hi, With direct sql statement, dividing 2 columns with CAST provide a good result (-- 1/2 = 0.5 and not 0). SELECT * , CAST(Mytable.colB AS FLOAT) / CAST(Mytable.colC AS FLOAT) AS CALCUL FROM Mytable When using a SA query with add_column, the result is not correct whether we use cast() or not