[sqlalchemy] Handling of currency values
I am converting an existing Firebird DB over to use sqlalchemy (0.4.0) and I can't figure out how to define the model for currency values. In the DB they are defined as numeric(18,2) default 0 and in the model I do e.g. sa.Column(u'cbb_currentvalue', sa.Numeric(precision=16,length=2,asdecimal=True)), However I don't get the trailing zero in my wxPython application, i.e. when I debug it I get: Decimal(26.2) or Decimal(0) I would have expected: Decimal(26.20) or Decimal(0.00) What am I missing? Appreciate any hints on this Werner --~--~-~--~~~---~--~~ 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] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Handling of currency values
according to sqlalchemy/types.py, the Decimal() is used straight away, without any precision etc stuff. the numeric(precision/length) are only for the db. i assume u have to use some precision-context around your db-related stuff. Werner F. Bruhin wrote: I am converting an existing Firebird DB over to use sqlalchemy (0.4.0) and I can't figure out how to define the model for currency values. In the DB they are defined as numeric(18,2) default 0 and in the model I do e.g. sa.Column(u'cbb_currentvalue', sa.Numeric(precision=16,length=2,asdecimal=True)), However I don't get the trailing zero in my wxPython application, i.e. when I debug it I get: Decimal(26.2) or Decimal(0) I would have expected: Decimal(26.20) or Decimal(0.00) What am I missing? Appreciate any hints on this Werner --~--~-~--~~~---~--~~ 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] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] expunge vs clear
I'm using an orm configuration with a sessionmaker().mapper doing the mapping between my classes and my metadata. The documentation says that doing a Session.clear() should do the equivalent of a Session.expunge(inst) for all instances attached to the session. I have one instance attached to the session, and do a Session.clear(); but if I then re-query to get that instance, I get InvalidRequestError: Could not update instance '[EMAIL PROTECTED]', identity key (class 'cobalt.model.base.Job', ('localhost', 0), None); a different instance with the same identity key already exists in this session. If I replace the Session.close() with a Session.expunge(inst), the error goes away. Any ideas? ~jon --~--~-~--~~~---~--~~ 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] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] How do I Instantiate a class with an Auto-assigned Key ID
our members table has an ID as the primary key with an auto-assigned key ID. When we create the class it is instantiated with the ID and also returns an ID. obviously if we provide an ID it conflicts with the auto-generated ID. and if we don't provide an ID it says we didn't provide enough variables to instantiate the class so how do we define our class so that it can return an ID but doesn't require one to instantiate the class? John --~--~-~--~~~---~--~~ 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] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---